The history of Moroccan railways begins with soldiers, not passengers. The first rails laid in Morocco were narrow-gauge military lines, built to move troops and supplies across a country that had no railway at all. Within a few decades those rough tracks became a standard-gauge network linking Tangier to Marrakech, and within a century the same network carried Africa's first high-speed train. The history of Moroccan railways is, in short, the story of a country learning to move — from mule tracks to 320 km/h.
This guide follows that story, from the military lines of the 1910s to Al Boraq and the trains Moroccans ride today. Where sources disagree about a date, this guide says so plainly, because the history of Moroccan railways has several dates that depend on whether you count the first train, the finished line or the official opening.
Our History & Heritage section covers the wider story of the country. LahbabiGuide is written by travellers who live in Morocco — read more about us. For the port cities the trains served, see our history of Moroccan ports.

In this guide
- Moroccan Railways at a Glance
- The First Rails: Narrow-Gauge Military Lines
- The Tangier–Fez Line: A Railway Across Three Zones
- The Casablanca–Marrakech Line and the Strategic Spine
- The History of Moroccan Railways Under the Protectorate
- The Oriental Desert Line: Oujda to Bouarfa
- Phosphate Trains: The Freight That Paid for the Network
- ONCF: One Railway for an Independent Morocco
- Al Boraq: Africa's First High-Speed Train
- The Great Stations of Morocco
- Timeline: From Steam to Al Boraq
- Riding the Rails Today: Routes, Times and Fares
- What the Records Do Not Tell Us
- Frequently Asked Questions
- Conclusion
Moroccan Railways at a Glance
| Fact | Detail |
|---|---|
| First railway | Narrow-gauge military lines from 1916; first public line Casablanca–Berrechid, 1908 |
| First standard-gauge line | Tangier–Fez, finished 1927 (315 km) |
| National operator | ONCF (Office National des Chemins de Fer), founded 1963 |
| Network today | About 2,100–2,300 km of standard-gauge track, over 1,000 km electrified |
| High-speed line | Al Boraq, Tangier–Kenitra, opened 15 November 2018 |
| Top speed | 320 km/h on the Tangier–Kenitra high-speed section |
| Fastest journey | Tangier–Casablanca in about 2 hours 10 minutes |
| Main freight | Phosphates from Khouribga to the ports of Casablanca and Jorf Lasfar |
The table gives the shape of the history of Moroccan railways at a glance.
The First Rails: Narrow-Gauge Military Lines
Before the railway, crossing Morocco meant days on a mule track. After the Treaty of Algeciras in 1906, the great powers agreed that no standard-gauge railway would be built until the Tangier–Fez line was complete — so the French army built narrow-gauge lines instead, at 600 mm gauge, to move soldiers and supplies.
Construction began in earnest in 1916, with military lines spreading inland from the coast. A private line had already linked the sultan's palace in Meknes to his Agdal garden, and in 1907 the French Compagnie Marocaine built a line from Casablanca port to a quarry at Roches Noires. The first public line followed in 1908, running 83 km from Casablanca to Berrechid; by 1935 French Morocco had more than 1,700 km of narrow-gauge track.
Almost none of it survives, but the military lines proved that railways could cross Moroccan terrain — a first, rough chapter in the history of Moroccan railways.
The Tangier–Fez Line: A Railway Across Three Zones
The first great standard-gauge project was the Tangier–Fez line, complicated before a single sleeper was laid. The 315 km route crossed three political zones: 18 km in the International Zone of Tangier, 93 km in the Spanish zone and 204 km in the French zone. So in 1919 the Compagnie Franco-Espagnole du Chemin de Fer de Tanger à Fès was created, backed by French and Spanish capital.
Construction began in 1919 and the line was finished in 1927, linking the port of Tangier to Fez, the old imperial capital. For Tangier, under international administration, the railway was a lifeline to the Moroccan interior.
The line stayed independent long after nationalisation: the Tangier–Fez company was only absorbed into ONCF in 1976. Today the route is part of the main line north, still following the alignment surveyed a century ago — a quiet survivor of the early history of Moroccan railways. Our guide to Tangier under international rule explains the politics of the zone it crossed.
The Casablanca–Marrakech Line and the Strategic Spine
While the Tangier–Fez line was being built in the north, another company laid the spine of the network. The Chemins de Fer du Maroc (CFM), founded in 1920, built two lines: Casablanca to Kenitra and Sidi Kacem, completed in 1925, and Casablanca to Marrakech. Together with the Fez–Oujda line, these formed the 948 km Chemins de fer stratégiques du Maroc, running from Marrakech to Oujda.
Here the sources disagree. The old Marrakech station was built in 1923, and the line was inaugurated on 1 December 1928 — yet some sources give 1936 as the year it was completed. The dates measure different things: the first trains reached Marrakech in the late 1920s, while the fully finished line is dated to 1936. This guide treats 1928 as the opening and 1936 as the completion.
The History of Moroccan Railways Under the Protectorate
The history of Moroccan railways under the French Protectorate (1912–1956) is a story of four companies building four separate railways. Alongside the CFM and the Tangier–Fez company, the Compagnie du Chemin de Fer du Maroc Oriental (CMO) built the eastern line from Fez to Oujda and on to Bouarfa. The fourth, the Mediterranean–Niger Railway, linked the coal region near Bouarfa to the Algerian rail system at Oujda, completing its route between Oran and Oujda in 1922.
These were colonial railways, and their geography shows it. The lines ran from mines to ports and from ports to garrisons: phosphates to Casablanca, coal to the Algerian border, troops to the interior. Cities that served no colonial purpose — the Atlantic south, the mountains, the desert oases — got no railway at all. That shape still defines the network: the trains serve the Atlantic axis and the north-east, and stop where the colonial map stopped. For the politics of that moment, see our guide to Moroccan independence in 1956.
The Oriental Desert Line: Oujda to Bouarfa
The strangest line in Morocco runs south from Oujda into the desert, across the high plateaux of the Oriental to the mining town of Bouarfa. The 305 km line was built in the 1920s and 1930s as part of the Mediterranean–Niger Railway, climbing to the highest point on the network near Tendrara. Its purpose was freight: zinc, lead, copper and barytes from the mines around Bouarfa, carried north to Oujda.
Passenger trains ran here too — one of the strangest services in the history of Moroccan railways — once a week in each direction until the early 1990s. Today the line survives on freight, with only a couple of trains a week, and on the Oriental Desert Express, a chartered tourist train that runs the route occasionally, taking ten to twelve hours and stopping to clear sand from the tracks.
The dates of this line are another case where two true dates look like a contradiction: one source gives 1927 as the completion of the Oujda–Bouarfa line, while another says the line reached Bouarfa in 1931. Both are right about different things: the CMO section was completed in 1927, while the Mediterranean–Niger segment from the south reached Bouarfa in 1931.
Phosphate Trains: The Freight That Paid for the Network
If passengers are the public face of Moroccan railways, phosphates are the business that pays for them. Morocco holds some of the largest phosphate reserves in the world, and the mines around Khouribga have fed the railway since the 1920s. Long freight trains carry raw phosphate from Khouribga to the ports of Casablanca and Jorf Lasfar, where it is exported or processed into fertiliser.
The phosphate traffic shaped the network. Freight still accounts for a large share of ONCF's business — tens of millions of tonnes a year — and the trains run day and night. The history of Moroccan railways cannot be told through passenger trains alone: without the phosphate revenue, the passenger network would look very different. The export earnings behind it feature in our history of the Moroccan dirham, and the harbours in our history of Moroccan ports.
ONCF: One Railway for an Independent Morocco
Independence in 1956 left Morocco with four separate railway companies, and it took seven years to bring them together. ONCF — the Office National des Chemins de Fer — was created by royal decree on 5 August 1963, merging the CFM, the eastern railway and the Mediterranean–Niger lines into one state-owned operator. It was the great unifying moment in the history of Moroccan railways. The Tangier–Fez company stayed outside until 1976.
ONCF inherited about 2,100 km of standard-gauge track, and its first decades were spent making the fragments into a system: unifying timetables, renewing track and wires, and double-tracking the busiest sections. Electrification spread steadily — the classic network runs on 3,000 V DC, with just over 1,000 km electrified — while the lines east of Fez to Oujda stayed diesel, as they still are today.
ONCF carried about 38 million passengers in 2013 and more than 55 million in 2024, and its freight runs to tens of millions of tonnes a year.
Al Boraq: Africa's First High-Speed Train
On 15 November 2018, King Mohammed VI inaugurated the Al Boraq high-speed line, and Africa gained its first high-speed railway. The new 186 km line runs from Tangier to Kenitra; commercial services began on 26 November 2018. The trains are Alstom Euroduplex double-decker sets, named Al Boraq after the winged steed of Islamic tradition, running at up to 320 km/h. For the full technical account, see Rail transport in Morocco on Wikipedia.
The effect on journey times was dramatic. Tangier to Casablanca fell from 4 hours 45 minutes to about 2 hours 10 minutes, and Tangier to Rabat to about 1 hour 20 minutes. Trains run roughly hourly from 06:00 to 21:00, stopping at Tanger-Ville, Kenitra, Rabat-Agdal and Casa-Voyageurs. The service is the flagship of the history of Moroccan railways in the 21st century — and the first phase of a much larger plan.
That plan is already moving. In April 2025, construction began on a 430 km high-speed extension from Kenitra to Marrakech, via Rabat and Casablanca, targeting completion by 2029, ahead of the 2030 World Cup that Morocco will co-host.

The Great Stations of Morocco
A railway is also its stations, and Morocco's are among the most handsome in Africa. Casa-Voyageurs in Casablanca is the busiest, the hub where Al Boraq meets the Al Atlas trains for Fez, Marrakech and Oujda. Rabat has two main stations: Rabat-Ville, near the medina, and the newer Rabat-Agdal, which serves the high-speed trains.
Each station carries a piece of the history of Moroccan railways. Marrakech station, rebuilt in 2008, keeps the memory of its 1923 predecessor a hundred metres away. The older stations of the Protectorate era — arched windows, tiled halls, clock towers — were built as civic monuments, not just waiting rooms, and many still serve exactly as designed. Their style borrows from the wider tradition in our history of Moroccan architecture. Our Casablanca travel guide and Marrakech travel guide explain how to use each city's station on arrival.

Timeline: From Steam to Al Boraq
| Date | Event |
|---|---|
| 1906 | Treaty of Algeciras: no standard-gauge railway until Tangier–Fez is complete |
| 1907 | Casablanca port to Roches Noires quarry line built |
| 1908 | First public line opens: Casablanca–Berrechid, 83 km, 500 mm gauge |
| 1916 | French army begins building 600 mm narrow-gauge military lines |
| 1919 | Compagnie Franco-Espagnole du Tanger à Fès founded; construction starts |
| 1922 | Mediterranean–Niger standard-gauge route Oran–Oujda completed |
| 1923 | Marrakech station built; Casablanca–Kenitra line completed 1925 |
| 1927 | Tangier–Fez line finished (315 km); Oujda–Bouarfa section completed |
| 1928 | Casablanca–Marrakech line inaugurated, 1 December |
| 1931 | Mediterranean–Niger line reaches Bouarfa from the south |
| 1935 | Narrow-gauge network in French Morocco exceeds 1,700 km |
| 1936 | Casablanca–Marrakech line recorded as fully completed |
| 1956 | Moroccan independence; railways still run by four companies |
| 1963 | ONCF founded by dahir, 5 August, merging the companies |
| 1976 | Tangier–Fez company absorbed into ONCF |
| 1982 | Nouaceur–Jorf Lasfar freight line opens |
| 1992 | Railway to Mohammed V International Airport opens |
| 2008 | New Marrakech station opens, 10 August |
| 2009 | Tangier Med port rail link opens, 17 June |
| 2018 | Al Boraq inaugurated 15 November; commercial service from 26 November |
| 2025 | Construction begins on Kenitra–Marrakech high-speed extension |
The timeline shows the shape of the whole history of Moroccan railways: a slow military beginning, a burst of colonial building in the 1920s, nationalisation in 1963, and the high-speed leap of 2018.
Riding the Rails Today: Routes, Times and Fares
Today's network has two faces: Al Boraq on the Tangier–Casablanca axis, and Al Atlas intercity trains everywhere else. Al Atlas trains link Casablanca with Fez, Marrakech and Oujda, and Fez with Marrakech directly. The history of Moroccan railways is still being written by the passengers on these trains.
Fares use dynamic pricing, like airlines: the same seat costs less weeks ahead and more on the day. The ranges below are planning ranges in Moroccan dirhams, checked November 2026 — confirm before travel on the ONCF site or app.
| Route | Train | Time | 2nd class | 1st class |
|---|---|---|---|---|
| Tangier–Casablanca | Al Boraq | ~2h 10m | 149–224 MAD (about $15–22) | 229–350 MAD (about $23–35) |
| Tangier–Rabat | Al Boraq | ~1h 20m | 110–172 MAD (about $11–17) | 149–224 MAD (about $15–22) |
| Tangier–Kenitra | Al Boraq | ~50 min | 75–110 MAD (about $8–11) | 129–180 MAD (about $13–18) |
| Casablanca–Marrakech | Al Atlas | ~2h 55m | 90–140 MAD (about $9–14) | 120–190 MAD (about $12–19) |
Book early: ONCF's "Yalla" advance fares start from 89 MAD in second class and 129 MAD in first on Al Boraq, for a limited number of seats bought at least seven days ahead. Every ticket includes a reserved seat; first class buys a wider seat plus lounge access at the main stations.
What the Records Do Not Tell Us
A good history says what it does not know, and the history of Moroccan railways has honest gaps. First, there is no single agreed date for the "first railway" in Morocco: 1906, 1907 and 1908 are all defended, depending on whether you count the treaty, the quarry line at Casablanca, or the first public line to Berrechid.
Second, the Casablanca–Marrakech completion date is unsettled: 1928 marks the inauguration, while 1936 is the date some sources give for full completion. Third, the network's total length varies by source — about 2,100 km or 2,295 km — because counts differ on year, sidings and freight branches. Finally, the narrow-gauge military lines left few records: their routes are known in outline, but the opening dates of many branches were never published.
Frequently Asked Questions
When did railways first come to Morocco?
The first rails were narrow-gauge military lines built from 1916, but the first public line opened in 1908, between Casablanca and Berrechid. The first standard-gauge line, Tangier–Fez, was finished in 1927. The history of Moroccan railways therefore has three different "firsts", and which one counts depends on what you mean by a railway.
What is Al Boraq?
Al Boraq is Morocco's high-speed train service, running between Tangier and Casablanca since November 2018. It is Africa's first high-speed railway, reaching 320 km/h on the Tangier–Kenitra section, with Tangier–Casablanca in about 2 hours 10 minutes.
When was ONCF founded?
ONCF, the Office National des Chemins de Fer, was founded on 5 August 1963 by royal decree, merging the Protectorate-era railway companies into one state-owned operator. The Tangier–Fez company stayed separate until 1976, a late footnote in the history of Moroccan railways.
How much does the train from Tangier to Casablanca cost?
On Al Boraq, second class typically costs 149–224 MAD (about $15–22) and first class 229–350 MAD (about $23–35), with "Yalla" advance fares from 89 MAD in second class. Prices are dynamic, so book early. All fares are planning ranges checked November 2026 — confirm before travel.
Does Morocco have a sleeper train?
Yes. Overnight trains run to Oujda from Marrakech and Tangier via Casablanca, Rabat and Fez, with couchette and sleeper accommodation.
Can I ride the Oriental Desert Express?
Only occasionally. The Oriental Desert Express is a chartered tourist train, not a scheduled service, running the Oujda–Bouarfa desert line a few times a year through ONCF's Supratours arm. Places are booked as part of a tour package.
Conclusion
The history of Moroccan railways runs from a quarry siding at Casablanca to a high-speed line that crosses the country at 320 km/h. It began as a military tool, became a colonial business carrying phosphates and coal to the sea, and is now a national railway Moroccans use every day. The narrow-gauge lines are gone, the four colonial companies are one, and the steam locomotives are museum pieces.
Yet the shape laid down a century ago still governs the map: the Atlantic spine from Tangier to Marrakech, the eastern line to Oujda, the desert branch to Bouarfa. The high-speed line to Marrakech is due by 2029. When it opens, the history of Moroccan railways will gain its newest page.