In a dramatic late-night session, parliament approved the most significant legislative package in a decade.