The train appeared as a dot on the plain south of Settat and passed the viewing platform four seconds later, a white streak and a pressure wave that lifted the hats off two engineers. The speedometer in the cab, a video feed showed, read 322.

Morocco’s national railway began high-speed test runs this week on the first 180-kilometer section of the extension of its Al Boraq line, which will carry the country’s bullet trains from Kenitra, north of Rabat, through Casablanca to Marrakech. The full 430-kilometer line is due to open in late 2029, a few months before Morocco co-hosts the World Cup with Spain and Portugal, and will cut the journey from Tangier to Marrakech from more than five hours to about two and a half.

“The World Cup gave us a date we cannot move,” said Yassine Benkirane, the railway’s project director for the southern extension, speaking at the test site. “That focuses the mind. We are 11 months ahead of where the first line was at the same stage.”

The original Al Boraq, which opened in 2018 between Tangier and Kenitra, is still the only high-speed railway in Africa. It carried 5.6 million passengers last year and, by the railway’s account, turned an operating profit from its second year. The extension, budgeted at 53 billion dirhams, about $5.3 billion, is financed by French and Moroccan state loans, the African Development Bank and a Gulf sovereign fund, with trains built in France and, for the first time, partly assembled at a new plant in Fez.

The line is part of a transport buildup that the government has tied explicitly to the tournament, including a new terminal at Casablanca airport, a 115,000-seat stadium near Benslimane that would be the largest in the world, and tram extensions in Rabat and Casablanca. Critics question the spending in a country where a quarter of young people are unemployed and rural areas lack basic roads.

“A train from Casablanca to Marrakech serves tourists and the urban middle class,” said Khadija El Amrani, an economist at Cadi Ayyad University in Marrakech. “The people who harvest the olives along the line will watch it pass. The question for 2031 is what remains for them.”

The railway counters that the line will free capacity on the existing tracks for freight and regional trains, and that 85 percent of the construction workforce of 9,000 is Moroccan. Planners are already sketching a further extension to Agadir on the Atlantic coast, which would require tunneling through the High Atlas foothills.

At Settat, the test train made four more passes on Thursday, each a little faster, before returning to its depot. A group of schoolchildren brought to watch from a nearby village were asked afterward what they had seen. “Nothing,” one boy said. “It was too fast.”