It has been controversial because opposition lawmakers say Japanese ships could be pressed into combat or protecting foreign ships in an emergency.
The two Japanese destroyers, Sazanami and Samidare, which are also carrying two SH-60K patrol helicopters and a pair of speedboats, are expected to reach Somali waters in early April. Together they carry about 400 sailors, including specially trained commandos.
About 1,000 people watched from the dock, a brass band played and Prime Minister Taro Aso was on hand to see the ships off.
"It is well known that piracy is growing in the Gulf of Aden," Aso said. "We hope you will fulfill your mission and return safely."
Authorities say marauding criminals in speedboats attacked more than 100 ships off Somalia's coast last year, including high-profile hijackings with multimillion-dollar ransom demands.
Japan's ships can only be deployed to protect Japanese boats - about 2,000 of them pass through waters near Somalia every year
- and their crews.
Ruling party members have argued the battle against piracy is more a crime-fighting operation than a military one and does not violate Japan's pacifist constitution, which limits Japan's military to defensive operations.
To allow the dispatch, Japan's Cabinet has also approved a new anti-piracy bill, designed to relax restrictions on the use of arms by personnel on navy ships if engaged by pirates and allow vessels to escort foreign ships in danger.
Japan's dispatch comes as more than a dozen warships from countries including Britain, the United States, France, China and Germany are guarding the region.