The 15-nation Security Council expressed fears that the pirates were becoming "increasingly violent" and using heavier weaponry, saying ships and aircraft should use "the necessary means'' to stop attacks.
Somalia, a nation of around eight million people, has been without a functioning
government since fighters from several factions overthrew the then president, Mohamed Siad Barre, in 1991.
Rise in hijackings
The legally binding UN resolution applies only to pirates off Somalia, whose 3,700km-long coastline is the longest in Africa and is close to busy shipping routes that connect the Indian Ocean with the Red Sea.
Most pirate attacks occur in the Gulf of Aden to the north of Somalia, however recently pirates have been targeting Indian Ocean waters off eastern Somalia.
More than 60 ships have been attacked in the area this year alone.
The Security Council move follows the capture by Somalian pirates last month of a Ukrainian ship, the MV Faina, with 33 military tanks on board.
Pirates who seized the vessel initially demanded a $20m ransom and warned they would counter any attempts to rescue the ship. Six naval warships have surrounded the vessel.
The Security Council had passed a similar resolution in June, giving countries the right to combat the rise in the hijacking of ships around Somalia which are subsequently held to ransom.