The whistle sounds across the arid plains of scrub brush and exposed rocky cliffs. It blares through the narrow, crowded corridors of city market stalls, piles of clothes and hot red peppers lying a mere arm’s length away from the vibrating metal track. Its rattling coaches draw stares as children run toward it, waving, as it leaves Lagos, Nigeria’s massive southwestern city, on the long trip north to Kano. But in the north, boys wearing tattered soccer jerseys herding cattle watch impassively, with machetes and long-barreled guns over their shoulders.

The train is back in Nigeria, and the 35-hour trip along its 700-mile route offers a glimpse of the nation’s history and landscapes while also allowing travelers to see its ethnic and religious diversity firsthand.

As a resident of Nigeria for more than three years, I can say the trip also offers a bit of the daily, careening madness of life in Africa’s most populous nation, a place where few have access to electricity, armed police demand money at checkpoints and nothing ever seems to go according to plan.

Nigeria reopened its train line to the north Dec. 21, marking the end of a $166 million project to rebuild portions of the abandoned line washed out years earlier. Before the restoration, it had been a decade since the last Lagos-to-Kano run, and train service elsewhere had deteriorated to a crawl. The state-owned China Civil Engineering Construction Corp. rebuilt the southern portion of the line, while a Nigerian company handled the rest.

The rebirth of the lines constitutes a major economic relief to the poor who want to travel in a country where most earn less than $1 a day. Airline tickets remain out of reach for many, and journeys over the nation’s crumbling road network can be dangerous. The cheapest train ticket available costs $13.

But while the route is newly restored, much of the infrastructure is old. “I want them to improve more, because most of the things you see, they are outdated,” shouted Bello Adebayo, 50, seated in a clacking, worn passenger car made decades ago. “But due to the pressure of the masses, we have to manage it. ... No one will complain. It’s OK, for now.”

On the Friday morning of my own trip, the cavernous lobby of the train line’s Lagos terminus filled with travelers. Young Muslim girls in hijab sat and waited amid colorful plastic bags filled with belongings. Men carried their belongings on their heads, including one precariously balancing suitcases and a motorcycle.

Many of those traveling north on the train, called the Ooni of Ife, appeared to be Muslims returning home. While Nigeria is predominantly divided into a Christian south and a Muslim north, the two faiths live together largely peacefully and intermarry in sprawling Lagos. All of Nigeria’s more than 250 ethnic groups can be found on the city’s busy streets, hustling out a living otherwise not possible in their home regions.

However, radical Islamic extremists have been carrying out a bloody guerrilla fight with Nigeria’s weak central government in the north for more than two years. Foreigners also have become a new target of extremists, often killed while in captivity. That’s why a team of Nigeria federal police officers carrying Kalashnikov assault rifles boarded the train with the passengers. They would accompany it all the way to Kano.

On this trip, people crammed into the second-class cabin, spilling out into the aisles in stifling heat. But passengers weren’t the main reason British colonialists built the narrow-track lines at the start of the 1900s. Instead, they wanted it to carry tin mined from the central city of Jos, peanuts harvested across the north, and other commodities to Lagos, then the colonial capital. The restored line follows that route, bypassing Abuja, the Nigerian capital since 1991, in a wide swing west.

After Nigeria’s independence in 1960, the trains became notorious for carrying the slaughtered dead of Nigeria’s Igbo people to their southeast homes after riots in the north. The nation’s 1960s civil war followed, killing some 1 million people. As corruption fueled by oil money gripped the country, the railroad began its slow, decades-long collapse. The nation paid millions of dollars to Romanians, Indians and later the Chinese to manage promised improvements that never came.

Facilities and infrastructure leave much to be desired. The old cars and sometimes aging rails offer some bumpy travel and even a few moments of panic when a particularly hard strike comes. Muslim passengers lack space to pray, rushing down off the train at stops to lay their prayer mats on the gravel.

Inside the bar car, 75-year-old Sanya Olu sat on a plastic lawn chair, her head resting wearily on her fist. She had bought a ticket for first-class, but it had been oversold, she said. So instead, she spent her trip in the chair she’d brought, en route to Kaduna to verify her status as a pensioner.

“They have just started and see how it is congested; it is full,” Olu said.