Media playback is unsupported on your device Media caption How the new legislation will change Japan's military role on the international stage

Japan's parliament has voted to allow the military to fight overseas for the first time since the end of World War Two 70 years ago.

A vote on the new law was delayed for several hours as the opposition tried to stop the measure coming into force.

Outside, demonstrators rallied in a last-ditch show of protest.

Many Japanese are attached to the pacifist provisions in the constitution which banned fighting overseas.

The bills have already passed through the government-dominated lower house.

Image copyright AP Image caption There was heavy security outside parliament ahead of the vote

The government says that the changes in defence policy are vital to meet new military challenges such as those posed from a rising China.

It wanted to hold the vote before a five-day holiday begins on Saturday. The governing coalition has a majority in both chambers of the Diet, meaning that ultimately the opposition camp was powerless to stop the measure becoming law.

Masaaki Yamazaki, the president of the upper house, said the bills were passed with 148 lawmakers voting in support and 90 against.

More than 200 hours have been spent deliberating the legislation, the Japan Times reported, and its approval by parliament fulfils one of Prime Minister Shinzo Abe's long-held ambitions.

On Thursday, opposition politicians tried to physically delay proceedings ahead of a committee vote on the bills.

Media playback is unsupported on your device Media caption Scuffles broke out in parliament amid wrangling over Japan's security bill

What is collective self-defence?

Japan's post-World War Two constitution bars it from using force to resolve international conflicts except in cases of self-defence.

Mr Abe's government has pushed for security legislation that would allow Japan's military to mobilise overseas when these three conditions are met:

when Japan is attacked, or when a close ally is attacked, and the result threatens Japan's survival and poses a clear danger to people

when there is no other appropriate means available to repel the attack and ensure Japan's survival and protect its people

use of force is restricted to a necessary minimum

What's behind Japan's military shift?

The bills prompted large public protests for months.

The changes re-interpret rather than formally change the constitution. But critics say this will violate the pacifist constitution and could lead Japan into unnecessary US-led wars abroad.

Image copyright EPA Image caption Prime Minister Abe had hoped to have the bill passed before a five-day holiday started on Saturday

Image copyright AP Image caption Demonstrators rallied in a last-ditch show of protest against the legislation on Friday

Speaking in parliament on Friday, Akira Gunji, of the opposition Democratic party, said: "We should not allow such a dangerous government to continue like this.

"Prime Minister Abe's security bill is a threat to our legal framework."

Supporters of the measures, which are backed by Washington, insist they are essential for the defence of Japan and its regional allies, and will permit greater involvement in peacekeeping activities around the world.

What kinds of military actions would the laws allow?

Japan would be able to provide logistical support to South Korea if the North invaded, though Mr Abe has said it would still be against the constitution to send Japanese troops to fight on Korean soil.

It would be legal for Japan to shoot down a North Korean missile headed for the US. Currently, they have to threaten Japan to justify shooting them down. North Korea is thought to be several years from being able to hit mainland US targets though.

Military action to keep shipping lanes secure, such as minesweeping, even if in an active conflict zone, might be allowed if the restriction on shipping was severe enough to constitute a threat to Japan's survival. But there have been different answers on how severe that restriction would have to be - especially relevant for resource-poor Japan. The deputy leader of the Mr Abe's Liberal Democratic Party (LDP), Masahiko Komura, has said that relatively minor problems like an oil price increase would not be enough - there would have to be a clear danger to people in Japan.

Armed involvement in hostage rescues would also become possible. In January 2013, 10 Japanese hostages were killed at the Amenas gas plant in Algeria.

Regional limits on Japanese military support for US and other foreign armed forces would also be eliminated.

Critics have focused on what they say is ambiguity in how the principles of the legislation will be interpreted, and the possibility that future governments will interpret them more broadly.