Japan's parliament has approved contentious legislation to loosen constraints on the country's military, giving it a greater role.

The approval at the upper house in the early hours of Saturday makes the legislation into law, loosening post-World War II constraints on use of force by the military to its own self-defense only.

The legislation, passed by the more powerful lower house in July, sparked sizeable protests and debate about whether the nation should shift away from its pacifist ways to face growing security challenges.