MANAMA, Bahrain (CNN) -- U.S. Navy snipers fatally shot three pirates holding an American cargo-ship captain hostage after seeing that one of the pirates "had an AK-47 leveled at the captain's back," a military official said Sunday.

The captain, who'd been held in a lifeboat in the Indian Ocean since Wednesday, was rescued uninjured, Navy Vice Adm. Bill Gortney told reporters.

Capt. Richard Phillips' ship, the Maersk Alabama, was stormed by pirates 350 miles off Somalia on Wednesday morning. He was "resting comfortably" on the USS Boxer after his rescue Sunday night, according to the Navy.

Phillips contacted his family and received a routine medical exam after his rescue at 7:19 p.m. (12:19 p.m. ET), the Navy Central Command said. Video from aboard the Boxer showed a smiling Phillips shaking hands with Navy personnel.

"The captain is in good health. He's showered up and in a clean set of clothes," Gortney said in a telephone news conference from Navy Central Command in Bahrain.

In Phillips' hometown of Underhill, Vermont, Maersk spokeswoman Alison McColl said Phillips' wife, Andrea, had spoken to her husband by phone after his rescue.

"She was laughing while she was on the phone with him," McColl told reporters. "She was saying his trademark sense of humor was still very much intact, and he's in great spirits. If you guys could have seen her light up when she talked to him, it was really remarkable." Watch spokeswoman read statement from Phillips' family »

U.S. forces moved to rescue Phillips after seeing him in imminent danger on the lifeboat, Gortney said. A fourth pirate was negotiating Phillips' fate aboard the nearby USS Bainbridge.

"While working through the negotiations process tonight, the on-scene commander from the Bainbridge made the decision that the captain's life was in immediate danger, and the three pirates were killed," Gortney said. "The pirate who surrendered earlier today is being treated humanely; his counterparts who continued to fight paid with their lives."

Don't Miss

The on-scene commander gave the shooters approval to open fire after seeing that "one of the pirates had an AK-47 leveled at the captain's back," Gortney said.

Seas in the area were getting rough at the time of the rescue, Gortney said, and the Bainbridge was towing the lifeboat presumably to calmer waters with a towline about 82 feet long.

A senior defense official told CNN that each pirate was shot in the head.

After the shooting, special operations personnel shimmied along the tow rope to ensure the pirates were dead and freed Phillips, the official said.

The official added that the pirates had become increasingly agitated over the past day, and negotiations were not going well.

The fourth pirate was aboard the Bainbridge most of the day and told military negotiators that he wasn't going back to the other pirates, according to a defense official with knowledge of the situation.

Federal prosecutors would be "reviewing the evidence and other issues" to determine whether that pirate would be prosecuted in the United States, Justice Department spokesman Dean Boyd said.

It's the first time in modern history that the United States has in custody a pirate who carried out an attack on a U.S. citizen, said a senior U.S. official with knowledge of the situation. The source said figuring out what to do with the pirate is a sensitive issue.

Phillips' rescue came a day after he dove into the water in an attempt to escape his captors, Gortney said. The pirates "shot in the water at him" but eventually recaptured him, Gortney said.

Maersk Line Limited President and CEO John Reinhart called Phillips "a leader of men ... [and] a brave and courageous man."

He said he has spoken with Phillips and said the captain is "feeling quite good." Phillips and his family, through Reinhart, expressed gratitude to the U.S. Navy.

"I actually was more concerned for his family," said Adm. Rick Gurnon, head of the Massachusetts Maritime Academy, where Phillips had trained. "As a captain in sea, in a lifeboat, he was comfortable -- even if he was sharing it with Somali pirates." Watch Massachusetts Maritime Academy celebrate rescue »

Gurnon stressed that while Phillips was rescued, more than 200 mariners remain captives at sea.

"The pirates have a great business model that works for them: See ships, take ransom, make millions," he told reporters.

At the White House, President Obama issued a statement saying he is "very pleased that Capt. Phillips has been rescued and is safely on board the USS Boxer."

"His safety has been our principal concern, and I know this is a welcome relief to his family and his crew," Obama's statement said. "We remain resolved to halt the rise of piracy in this region."

Obama had given standing orders for the military to take "decisive action" if Phillips was in "imminent danger," Gortney said.

Phillips offered himself as a hostage after the pirates stormed the U.S.-flagged Alabama Wednesday morning, according to Maersk.

Crew members have said that after the pirates stormed the ship, they overpowered one pirate and tied him up. The crew released the pirate Wednesday, hoping to exchange him for Phillips, but the pirates instead retreated to the lifeboat with Phillips, leaving the Alabama to its crew. View a timeline of the attack and its aftermath »

Maersk Alabama crew members, who guided the ship to port in Mombasa, Kenya, on Saturday, were "jubilant" when they received word of the rescue, a statement from the company said.

Gortney said the Alabama had reported being harassed by pirates the day before the pirates' successful attack on Wednesday. When the Alabama crew made the call, "our closest vessel from all the navies that were out there -- we have 16 navies that are patrolling those waters -- and the closest one was the USS Bainbridge, and it was over 300 nautical miles" away he said.