U.S. Marines rescued a hijacked German-owned cargo ship off the coast of Yemen on Thursday, boarding the vessel as dawn broke and apprehending nine pirates without firing a shot.

Two dozen Marine commandos took control of the Magellan Star, a container ship en route from Spain to Vietnam, by swarming the decks and surrounding the armed pirates before they had time to react, U.S. military officials said. The pirates, all Somali nationals, will remain in custody of the U.S. Navy until officials can decide whether they should be prosecuted or released.

"The pirates were definitely overmatched," Vice Adm. Mark I. Fox , commander of the U.S. Fifth Fleet in Bahrain, said in a telephone interview.

The rescue occurred less than 24 hours after pirates had captured the ship, the latest in a wave of maritime hijackings in the Gulf of Aden and the Indian Ocean, which contain some of the world's busiest shipping lanes.

The Marines were aided by the Magellan Star's wily 11-man crew, who had avoided being taken hostage by barricading themselves in a safe room as the pirates boarded the ship. The crew also killed the ship's engine, leaving the vessel to float dead in the water until help could arrive.

Frustrated, the pirates grabbed an emergency phone in the control room and called the ship's owner in Dortmund, Germany, demanding to know the crew's whereabouts and how to restart the engine.

"We said, 'Oh, the crew is on holiday,' " said Holger Roemer, an executive with Dr. Peters Group, the German firm that owns the vessel. "We also told them the engine was having trouble. They were very sour and told us a lot of not-very-nice words and hung up."

As the pirates stewed, the Marine commandos - assigned to the 15th Marine Expeditionary Unit's Maritime Raid Force and serving in the region as part of an international anti-piracy task force - prepared to intervene.

By early Thursday, the pirates found themselves surrounded by two U.S. warships, the Dubuque and the Princeton, as well as a Turkish frigate on patrol for the anti-piracy task force. Navy helicopters also hovered around the hijacked container ship, but the pirates - defiantly waving AK-47s - refused to surrender, Marine and Navy officials said.

About 5 a.m., the platoon of Marine commandos climbed on board the Magellan Star from boarding craft that had pulled alongside the ship. They subdued the pirates within minutes. Neither side fired any shots, the Marines said.

"It was a combination of speed and overwhelming force," Lt. Col. Joseph R. Clearfield, commanding officer of the Marines who boarded the ship, told reporters in a conference call. "At that point, I think they realized that resistance was futile."

It took longer to convince the barricaded crew that friendly forces had arrived. Hearing the commotion on the decks and fearing that the pirates were coming for them, crew members responded by retreating deeper into a warren of safe rooms inside the ship.