(For more coverage of the pirate crisis click on [nPIRATES]
* U.S. Navy said captain's life was in danger
* President Obama authorized use of force
* Pirates vow revenge against U.S. and France
* Jubilant celebration by crew in Kenya (Updates with captain's life in danger, details)
By Abdi Sheikh and Abdi Guled
MOGADISHU, April 12 (Reuters) - U.S. naval forces rescued cargo ship captain Richard Phillips from captivity at the hands of Somali pirates in a dramatic shootout that ended a five-day standoff, the U.S. Navy said on Sunday.
Phillips' life was in danger when 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 was in custody.
"I can tell you that he is free and that he is safe," Navy Lieutenant Commander John Daniels said.
The U.S. 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 U.S. Naval Central Command, said in a Pentagon briefing from Bahrain.
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.
The U.S. Navy 5th Fleet in Bahrain said the rescue took place at 12:19 p.m. EDT (1619 GMT) and the lifeboat had drifted to about 20 miles (32 km) from lawless Somalia's coast.
Phillips, captain of the U.S.-flagged Maersk Alabama container ship, had contacted his family, received a routine medical evaluation, and was 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.
CNN showed a photo of a smiling Phillips after his rescue.
Phillips' crew let off flares, hoisted an American flag and jumped for joy at news of their captain's rescue.
"We are very happy. He's a hero," one crew member of the Maersk Alabama shouted at journalists amid raucous celebrations on the deck of the vessel, docked in Kenya's Mombasa port. [nLC335299]
Phillips, 53, was the first American taken captive by Somali pirate gangs who have marauded in the busy Gulf of Aden and Indian Ocean shipping lanes for years.
Three U.S. warships had been watching the situation.
PIRATES VOW REVENGE
Obama, spared from having another thorny foreign policy crisis added to his troubles with the U.S. economic meltdown and Afghanistan, welcomed the rescue, praised the U.S. military and vowed to curb rampant piracy.
"To achieve that goal, we must continue to work with our partners to prevent future attacks, be prepared to interdict acts of piracy and ensure that those who commit acts of piracy are held accountable for their crimes," he said in a statement. [nN12330110]
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 French and the Americans will regret starting this killing. We do not kill, but take only ransom. We shall do something to anyone we see as French or American from now," Hussein, a pirate, told Reuters by satellite phone. [nLC343356]
The Maersk Alabama, a container ship carrying food aid for Somalis, was attacked far out in the Indian Ocean on Wednesday, but its 20 American crew apparently fought off the pirates and regained control.
Phillips volunteered to go with the pirates in a Maersk Alabama lifeboat in exchange for the crew, said Vice Adm. Bill Gortney, commander, U.S. Naval Forces Central Command.
"The actions of Captain Phillips and the civilian mariners of Maersk-Alabama were heroic. They fought back to regain control of their ship, and Captain Phillips selflessly put his life in the hands of these armed criminals in order to protect his crew," he said in a statement.
Joseph Murphy, whose son, Shane, was Phillips's second in command and took over the Alabama after pirates left with Phillips, said in a statement read by CNN, "Our prayers have been answered on this Easter Sunday."
"My son and our family will forever be indebted to Capt. Phillips for his bravery. If not for his incredible personal sacrifice, this kidnapping -- an act of terror -- could have turned out much worse," said Murphy.
"The captain is a hero," one crew member shouted from the 17,000-ton ship as it docked in Kenya's Mombasa port under darkness on Saturday. "He saved our lives by giving himself up."
LEGAL SYSTEM NEEDED
Experts had expected a quick end to the standoff, but the pirates held out for both a ransom and safe passage home. Friends told Reuters the gang wanted $2 million.
The saga has drawn world attention to the long-running piracy phenomenon off Somalia that has hiked shipping insurance costs and disrupted international trade.
Andrew Mwangura, coordinator of Mombasa-based East African Seafarers Assistance Program, said the rescue would change the stakes in future pirate attacks.
"This is a big wake-up to the pirates. It raises the stakes. Now they may be more violent, like the pirates of old," he said.
Pirates have generally treated hostages well, sometimes roasting goat meat for them and even passing phones round so they can call loved ones. The worst violence reported has been the occasional beating and no hostages are known to have been killed by pirates.
The drama underscored a need for new international agreements to allow other countries to protect shipments in Somali waters and try pirates, U.S. Coast Guard Commandant Adm. Thad Allen told U.S. net work ABC's "This Week". [nN12352211]
The U.S. Justice Department said in a statement it "will be reviewing the evidence and other issues to determine whether to seek prosecution in the United States." (Additional reporting by David Morgan and Randall Mikkelsen in Washington, Abdi Sheikh and Ibrahim Mohamed in Mogadishu, Jack Kimball, Celestine Achieng and Njuwa Maina in Mombasa, Andrew Cawthorne and Abdiaziz Hassan in Nairobi; Writing by Paul Eckert; Editing by Doina Chiacu)