Two boats full of pirates approached the Seabourn Spirit about 100 miles off the Somali coast and opened fire while the heavily armed bandits tried to get onboard, said Bruce Good, spokesman for the Miami-based Seabourn Cruise Line, a subsidiary of Carnival.

The crew enabled the ship to escape by shifting to high speed and changing course.

The 161-member crew gathered the passengers into a central lounge away from windows and decks during the attack, Good said.

Norman Fisher, 55, a passenger, said the captain tried to ram one of the pirate boats in an attempt to capsize it and stop the pirates from getting aboard.

“The captain didn’t sound the usual alarm because he was worried that people would run up on the deck thinking it was a fire, and that would be the worst place to be,” he said. “Instead he made an announcement … saying: ‘Stay inside, stay inside, we are under attack.’ “

The attackers never got close enough to board the Spirit, but one crew member was injured by shrapnel, cruise line President Deborah Natansohn said.

“These are very well-organized pirates,” said Andrew Mwangura, head of the Kenyan chapter of the Seafarers Assistance Program. “Somalia’s coastline is the most dangerous place in the region in terms of maritime security.”

The vessel’s 151 passengers, mostly Americans with some Australians and Europeans, were unhurt. The Press Association, a British news agency, said passengers awoke to the sound of gunfire as two 25-foot inflatable boats approached.

Edith Laird of Seattle, who was traveling with her daughter and a friend, told the BBC in an e-mail that her daughter saw the pirates through the window.

“There were at least three rocket-propelled grenades that hit the ship, one in a stateroom,” Laird wrote. “We had no idea that this ship could move as fast as it did and [the captain] did his best to run down the pirates.”

The Spirit was bound for Mombasa, Kenya, at the end of a 16-day voyage from Alexandria, Egypt. It was expected to reach the Seychelles on Monday, and then continue on its previous schedule to Singapore, company officials said.

The 440-foot, 10,000-ton ship, registered in the Bahamas, sustained minor damage, Good said. The liner, which had its maiden voyage in 1989, can accommodate 208 guests.