Two Japanese destroyers are patrolling in the Gulf of Aden
Japan's parliament has passed a law allowing its navy wider powers to fight piracy off the coast of Somalia.
The new law allows Japanese warships to protect all commercial vessels in the area and to fire at pirate vessels, but not at pirates themselves.
Japan has sent two destroyers and two surveillance planes to join the navies of more than 20 countries fighting piracy in the Gulf of Aden.
Japan's post-WWII pacifist constitution tightly restricts its military.
The bill was approved by the lower house of parliament in April. On Friday, the opposition-controlled upper house rejected it over concerns about expanding the role of Japan's military.
Just hours later, the lower house used its capacity to overrule the upper house and voted the bill into law with more than a two-thirds majority.
Previously, the Japanese force was only allowed to escort Japanese vessels, or those with Japanese cargoes or crews, and use weapons only for self-defence.
They will now be able to escort any ship and have more leeway to fire, such as at suspected pirate vessels which fail to heed warnings not to approach commercial vessels.
Pirates in the Gulf of Aden and the Indian Ocean near Somalia have attacked shipping in what is one of the world's busiest sea lanes, capturing vessels and crews to hold for ransom.