A Holland America cruise ship with more than 1,500 gay travelers was turned away from a port in Morocco over the weekend in what was to be a historic trip to a Muslim country.

The MS Nieuw Amsterdam was scheduled to dock in Casablanca on Saturday, but RSVP Vacations, which organized the trip, told its clients that the ship would have to go elsewhere.

The agency said the decision was made after the visit of a gay cruise ship turned into a public and potentially controversial matter.

Our port agent in Casablanca has advised us that authorities in Morocco have -- despite previous confirmations -- now denied our scheduled visit, the company said in a statement.

For all of us, this is a very disappointing development, it added. It was ultimately the decision by local authorities in Morocco that has necessitated us to adjust our plans.

The ship changed its route Sunday and docked in the southern Spanish port of Malaga.

Organizers emphasized Morocco's historic welcoming tolerance for gay tourists, despite the country's laws punishing homosexuality. The Islamic-inspired penal code bans sex outside marriage and punishes same-gender sexual relationships with six months to three years in jail.

The mostly American and European passengers were scheduled to visit the Hassan II Mosque and several souks -- or traditional marketplaces -- while docked in Casablanca. It was to be the only non-European leg of a week-long journey for the cruise liner, which sailed from Barcelona on Friday.

Moroccan tourism officials, however, deny that the ship was banned and claim its passengers were welcome in the country.

We don't ban cruise ships here, and we never ask our visitors about their sexual preferences, Morocco's tourism minister Lahcen Haddad told Reuters. When asked if the ship could still visit Morocco, he claimed, They can if the organizers want to.

Morocco is ruled by moderate Islamists of the Justice and Development Party, which came into power in December amid Arab revolts in the region. The party promised not to impose a strict moral code on visitors.

Morocco does not have the oil riches of its neighbors and counts on visitors to boost its economy and put its people to work. Tourism accounts for about 10 percent of Morocco's GDP and roughly 450,000 jobs.

READ ALSO: Under Mohamed Morsi, Will Egypt's Tourism Industry Conform To Islamic Law?

Post-Arab Spring Travel And Tourism In The Middle East: A Country-By-Country Look