The bill was approved by the upper house on Friday in a 126-94 vote and will boost a joint missile defence system Japan is working on with the United States.
The bill passed the more powerful lower house last month, meaning the legislation will now be enacted.
Japan's post-war pacifist constitution renounces the use of force to settle international disputes, but Tokyo has recently become increasingly concerned about dangers posed by North Korea's nuclear weapons and missile programmes.
Proponents argued the legislation was needed to respond quickly to an attack, rather than going through bureaucratic channels that could delay a response.
"If a missile comes flying into Japan, we have to shoot it down to protect the lives and property of the Japanese people before we can mobilise our defences," Defence Agency chief Yoshinori Ono said before the vote.
Critics were concerned the legislation would give Japan's military too much power to use force, but the bill was backed by the ruling party and passed easily.
Tokyo is jointly researching a missile defence system with the United States, and Ono said on Tuesday that Washington had agreed to let Japan manufacture new Patriot missile systems under licence.
He said the two countries signed an agreement in March allowing Japan to produce Patriot Advanced Capability-3, or PAC-3, missiles for planned deployment during fiscal 2006.
The missiles are designed to intercept and destroy incoming ballistic missiles, cruise missiles and enemy aircraft.
Washington has agreed to let
Japan manufacture new missiles
The missile defence system is one of several ways Japan is slowly moving away from its purely pacifist stance following the second world war.
The country is relaxing its long-time ban on arms exports to facilitate defence technology transfers with the United States related to the defence system.
Authorities are also considering amending the constitution to allow the military to play a greater role overseas.
North Korean worries
Worries in Japan about North Korea have risen as the communist country moves ahead with its nuclear weapons programmes.
A top North Korean official told a US television network last month that his government is building more nuclear bombs and is able to mount nuclear warheads on its missiles.
North Korea has test-fired short-range missiles many times in the past. In 2003, it launched short-range land-to-ship missiles at least three times during a period of heightened tensions over its nuclear weapons programme.
North Korea shocked Japan in 1998 by blasting a Taepodong-1 missile over its territory and into the Pacific Ocean. The North said it was an attempt to put a satellite in orbit.