Morocco’s trains are one of the best ways to get around the country: comfortable, scenic, and affordable. Yet many tourists run into trouble booking before they even arrive, because of a well-known problem with the official system. Here is how the network works and how to get your ticket without the hassle.

The Two Main Train Types

ONCF, the national railway, runs more than 4,000 km of track connecting all the major cities. Two types of train are worth knowing:

  • Al Boraq: Africa’s first high-speed line, opened in 2018. It reaches 320 km/h between Tangier, Kenitra, Rabat and Casablanca. Tangier to Casablanca takes about 2 hours 10 minutes, and Tangier to Rabat just 80 minutes. Trains leave roughly hourly, every seat is reserved, and there’s a café-bar car that makes the ride a pleasure.
  • Al Atlas: the standard network serving the rest of the country (Marrakech, Fes, Meknes, Oujda) at up to 160 km/h. Snack trolleys pass through the carriages. In the heat of summer the air conditioning can be unreliable, so choose a car marked “Climatisé” and, if you can, sit on the side away from the sun.

Some of the longest routes, notably Marrakech to Tangier, run overnight, which suits you if you’d rather sleep than spend the whole day in your seat.

What It Costs

Prices depend on the route and how early you book. As a rule, second class starts at around €5, first class around €10, and Al Boraq around €28. On short routes like Casablanca–Rabat, the gap between classes hardly matters. On longer journeys, first class gives real extra comfort for a small premium. Children aged 0 to 3 travel free. Booking opens six months before departure, and it pays to book early for popular routes, weekends and holidays, when second class fills up fast.

The Problem for Foreign Travelers

Few guides explain this, but it’s worth knowing before you try to book. The official site, oncf-voyages.ma, is geoblocked in many countries and may not load at all. Even when it does, its payment gateway is built to verify Moroccan cards and often rejects those issued abroad. Your card isn’t the problem: the fraud-detection system simply doesn’t recognize non-Moroccan card formats. Many North American and European travelers are affected.

How to Get Your Ticket

There are several dependable options, depending on how far ahead you’re booking and how much convenience you want:

  1. Use a third-party booking site. Some platforms resell ONCF and Al Boraq tickets, and international rail sites also cover Morocco. They accept foreign cards without local verification and usually offer an English checkout. This is the most reliable way to secure a ticket before you arrive.
  2. Download the ONCF Voyages app. The official app is available in Arabic, French and English and uses the same booking system as the website. You can manage tickets, apply discount cards and keep an e-ticket on your phone. It works well for most travelers, though some find sign-up awkward, especially the phone number format for non-Moroccan numbers, so be patient the first time.
  3. Try a VPN set to Europe. It’s not guaranteed, but travelers report that a French or Spanish IP address makes the site more likely to accept a foreign card, since it changes how the gateway reads the transaction’s origin. It costs nothing to try before paying a markup elsewhere.
  4. Buy in person. Ticket counters at major stations, including Casablanca Mohammed V Airport, sell tickets on the spot and accept cash and foreign cards. If you’re flying into Casablanca, buying your first connecting ticket at the airport is a simple solution and a good backup if online booking fails.

Our Recommendation

For your first ticket, especially if you’re booking from abroad, a third-party platform is the easiest route: English checkout, foreign cards accepted, and a ready-to-use e-ticket, with no need to deal with the official site. Once you’re in Morocco, station counters are a fully reliable way to buy further tickets, and the ONCF Voyages app becomes handy for checking timetables and managing the tickets you already hold.

A Note From Someone Living Here

The trains are excellent. This whole section exists only because of a quirk in the payment gateway, not because of any problem with the journey itself. Once your ticket is sorted, the ride is comfortable and scenic.

Quick Answers

  • Why won’t the ONCF website accept my card? Its payment gateway is designed to verify Moroccan cards and often rejects foreign ones. It’s a known gateway issue, not a problem with your card.
  • What’s the difference between Al Boraq and Al Atlas? Al Boraq is the high-speed line (up to 320 km/h) linking Tangier, Rabat and Casablanca. Al Atlas is the conventional network (max 160 km/h) serving the rest of the country, including Marrakech and Fes.
  • How far ahead can I book? Up to six months before departure, and early booking is advisable for popular routes on weekends and holidays.
  • Can I buy a ticket once I’m in Morocco? Yes. Counters at main stations, such as Casablanca Mohammed V Airport, sell tickets immediately for cash or foreign cards.
  • First or second class? On short routes there’s little difference. On longer trips, first class adds real comfort for a small extra cost.