"Gunmen in two or three speed boats opened fire on the Seabourn Spirit while it was about 70 nautical miles off Somalia," said Andrew Mwangura, programme coordinator for the Seafarers' Association in neighbouring Kenya.
None of the passengers or crew aboard ship was reported hurt in the incident which took place on Saturday morning.
"The captain managed to change the course of the vessel and speed away. Most of the passengers are believed to be Americans or Western Europeans. No one was hurt," Mwangura told Reuters.
The Indian Ocean waters off the Somali coast are classed as among the most dangerous in the world.
The 10,000-ton Bahamas-registered Seabourn Spirit was believed to be carrying about 300 passengers and crew from Alexandria in Egypt to the Kenyan port of Mombasa.
Its owners, Miami-based Seabourn Cruise Line, said the vessel had been rerouted to the Seychelles after the attack.
"Early this morning an attempt was made to gain access to the Seabourn Spirit while it was at sea," the company said in a statement. "The approach was successfully repelled."
A company official contacted in Britain gave no more details, but said all on board were safe."
"It is heading for the Seychelles now," she told Reuters.
Piracy off Somalia threatens shipping and has sabotaged the
Ships regularly demand armed
guards near Somali waters
delivery of food aid to more than half a million hungry people in the region, the United Nations said on Thursday.
Hijackers have commandeered two vessels used by the UN World Food Programme this year and ship owners now demand armed escorts to travel in the waters, the agency said.
This week, the London-based International Maritime Bureau said it knew of 27 pirate attacks off Somalia since March.
The attacks have highlighted insecurity in Somalia, which has had no government to enforce law and order since war lords ousted dictator Mohamed Siad Barre in 1991.