The British-owned Aurora left Gibraltar around 6:15 pm en route to Southhampton, England, its port of origin. About 2,000 passengers were on board.
Spanish authorities, who closed the border just before the ship docked Monday morning, said they expected to be re-open the border sometime after the ship's departure.
The closure stranded some Spainards who work in Gibraltar and irked British officials.
"We were obliged to halt traffic between Spain and the colony of Gibraltar given the absence of information on the virus," Spanish Health Minister Ana Pastor said.
Fifty passengers remained on board while crew members and the rest of the passengers, mostly Britons, were allowed to go ashore. Of the 50, only 11 were considered to be seriously ill with a highly contagious gastrointestinal bug called a norovirus, the ship's owner P&O Princess Cruises PLC said.
The ship was denied entry to a port in Greece on Friday, after more than 400 of the 1,800 passengers on board caught the bug. Such viruses are spread through food, water and close contact with infected people. Symptoms of diarrhea, vomiting and nausea usually last up to two days.
"It has been pretty ghastly," said British retiree Evelyn Gibbons. "I was in bed for some time. It was the most disappointing holiday I have ever had."
Earlier Monday, British Foreign Secretary Jack Straw called the border closure "unnecessary and disproportionate." Gibraltar Chief Minister Peter Caruana accused Spain of overreacting.
Spain and Britain regularly disagree over the sovereignty of the once-strategic military post. British forces captured the 1,400-foot-high rock from Spain in 1704. Spain formally ceded it nine years later, but has never given up on trying to get it back.
Late Spanish dictator Gen. Francisco Franco closed the border in 1969 and it was not reopened until 1985, 10 years after Franco's death.
Gibraltar frequently complains that Spanish authorities cause delays at the frontier as part of their campaign to reclaim the territory.
About 30,000 people live in the territory, which is now a major tourist resort with important offshore banking and port facilities.