The vote means nations will be able to send warships to tackle pirates
The UN Security Council has unanimously voted to allow countries to send warships into Somalia's territorial waters to tackle pirates.
The resolution permits countries that have the agreement of Somalia's interim government to use any means to repress acts of piracy for the next six months.
Twenty-six ships have been attacked by pirates in the waters in the past year.
The vote came as the UN launched separate peace talks with factions involved in Somalia's conflict.
But the Islamist opposition said face-to-face talks would not happen at the meeting in neighbouring Djibouti until the government set a timetable for the withdrawal of Ethiopian troops, who are supporting the government.
Somalia's coastal waters are near shipping routes connecting the Red Sea and the Indian Ocean, and the country's government is unable to police its own coastline.
Consequently, piracy is rife off Somalia's 1,800 mile-long coast, says the BBC UN correspondent Laura Trevelyan.
The resolution was drafted by France, the US and Panama.
Our correspondent says France originally wanted to expand the motion to allow piracy to be tackled in other areas, such as West Africa.
China, Vietnam and Libya said they voted for the measure because it only applies to Somalia, and does not affect the sovereignty of other countries.
But diplomats say the Security Council action is significant because it is using the force of international law to allow navies to chase pirates and armed robbers.
On Monday, Security Council envoys met representatives of the Somali government and the opposition at a luxury hotel on the shores of the Red Sea.
I am willing to do whatever it takes to promote peace and stability in Somalia
The talks, which are being held in Djibouti because Somalia is deemed too dangerous, are part of a UN plan to broker the first official direct talks between the Somali rivals.
But Abdirahman Abdishakur Warsame, deputy head of the Alliance for the Re-liberation of Somalia (ARS) said it would not agree to face-to-face talks until a timetable was in place for the Ethiopians to leave Somali territory.
"The Ethiopian presence is the main obstacle to [the] peace process, and the main obstacle to reach a lasting solution for Somalia," he said.
The Ethiopians helped the government oust Islamists from Mogadishu in December 2006.
But President Abdullahi Yusuf says there would be a security vacuum if the Ethiopians withdrew before being replaced by UN peacekeepers.
Aid agencies say 6,000 civilians have died in the past year in Mogadishu
"I am willing to do whatever it takes to promote peace and stability in Somalia," he said.
Somalia has not had a functioning national government since 1991.
An Islamist insurgency there has been mounting almost daily attacks on the weak government, which is backed by the United States, because Washington believes the Islamists are associated with al-Qaeda.
The UN says almost two million Somalis desperately need assistance.
A small contingent of African Union troops is in Mogadishu but has done little to quell the violence.
The talks are being boycotted by the hard-line al-Shabab militia, blamed for many of the attacks on government troops and their Ethiopian supporters.
The UN mission is due to travel to South Sudan on Tuesday.
It is also scheduled to visit the Democratic Republic of Congo, where millions of people have been displaced by fighting in the east of the country.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.