US naval forces have rescued cargo ship captain Richard Phillips from Somali pirates in a dramatic shootout.

Naval forces shot the pirates, freeing him unharmed and killing three of four pirates who had held him hostage on a lifeboat after trying to seize his vessel, the navy said.

The fourth pirate is in custody.

Lieutenant Commander John Daniels said the navy believed that Phillips, who tried to escape on Friday, faced imminent danger amid tense hostage talks with his captors and deteriorating sea conditions.

‘They were pointing the AK-47s at the captain,’ Vice Adm. William Gortney, head of the US Naval Central Command, said in a Pentagon briefing from Bahrain.

US President Barack Obama had granted the Pentagon's request for standing authority to use appropriate force to save the life of the captain, he said.

Mr Phillips, captain of the US-flagged Maersk Alabama container ship, had contacted his family, has received a routine medical evaluation, and is resting comfortably aboard the amphibious assault ship USS Boxer.

‘We are all absolutely thrilled to learn that Richard is safe and will be reunited with his family,’ Maersk Line chief executive John Reinhart said in a statement.

The ship's crew let off flares, hoisted a US flag and jumped for joy at news of their captain's rescue.

Mr Obama welcomed the rescue, praised the US military and vowed to curb rampant piracy.

Somali pirates were quick to vow revenge over Sunday's shooting, as well as a French military assault to rescue a yacht on Friday.

The Maersk Alabama, a container ship carrying food aid for Somalis, was attacked far out in the Indian Ocean on Wednesday, but its crew apparently fought off the pirates and regained control.
Vice Adm Gortney said Phillips volunteered to go with the pirates in a Maersk Alabama lifeboat in exchange for the crew.

Elsewhere, an Italian tug, the 75m Buccaneer, which was towing two barges, became the latest victim of the pirates last night.

10 Italians, five Romanians and a Croat are on board.

International bodies believe Somali pirates are holding about 17 ships with more than 270 crew members.