Damaged railway lines near Zolochiv.
Credit...Adam Ferguson for The New York Times

Ukraine’s 15,000-Mile Lifeline

How the country’s vast rail system has helped it withstand an invasion.

Listen to This Article

Audio Recording by Audm

To hear more audio stories from publications like The New York Times, download Audm for iPhone or Android.

On the night of Feb. 23, when Kyiv was still rife with rumors and denials about the Russian troops and weaponry amassing along the border, Oleksandr Kamyshin, the 38-year-old chief executive of Ukrzaliznytsia — Ukraine’s national rail system — sent a photograph to the management’s Telegram group chat in an attempt to settle everyone’s nerves. The photo showed him tucking his two sons, 8 and 12, into bed in their apartment in central Kyiv. The head of passenger services, Oleksandr Pertsovskyi, replied with a photo of his toddler taking a bath. The implication of both photos was clear: The leaders, and their families, were staying put.

Kamyshin had been in charge of Ukrzaliznytsia for only six months. Still in his trial period, he hadn’t even been offered a permanent contract. When he was hired, he espoused all the Western-approved jargon of railway reform that had been demanded of Ukraine for years — “higher freight yields,” “vertical integration,” “rolling-stock renewal,” “cargo turnover” and so on. Kamyshin had spent eight years on the management board of System Capital Management, an investment house belonging to Ukraine’s richest oligarch, Rinat Ahmetov, which oversaw the iron-ore and coal magnate’s freight trains. He ran international marathons, including the New York City Marathon, collected fine red wines and was a devoted fan of the internet-famous restaurateur Salt Bae, whom he once met in Istanbul.

When the bombing started at 4 a.m., Kamyshin decided there was no time for the Western management techniques he had championed. He sent his wife and children and a majority of the Ukrzaliznytsia leadership team west. A command cell of six stayed in the center of Ukraine, all of them career railway men (yes, only men) who could close their eyes and recite the railway map down to the names and sizes of stations, how many tracks ran into each. The team decided it was important to project strength and fearlessness — to show that Ukrainians would not be terrorized. Over the course of the next 100 days, these six men and Kamyshin would dictate where the trains would run, along which routes, what they would transport and where.

“We don’t have discussions, we don’t have a lot of opinions, we don’t have long conversations — all decisions are made instantly and they are binding,” Kamyshin told me in May. “I understood that if I sat down and took the time to make balanced decisions, it would be worse than a wrong decision.”

For safety, the cell decided to move around Ukraine by train, working out of the carriages; they also nominated their replacements, in the event that any of them were killed. Between saboteurs and Russian troops pouring into the country, they assumed they were being hunted, so they regularly changed locomotives, carriages and routes as they traveled from place to place.

Ukraine’s airspace was closed a few hours before the invasion, and movement in, out and around the country was immediately curtailed. The Russians attacked from multiple fronts — the land, the skies and the seas. They came overland from the north toward Kyiv and into Kharkiv; they went from Crimea in the south into Mariupol and Mykolaiv, and from the east into Luhansk and Donetsk, the regions known collectively as the Donbas.

In late February and through March, terrified Ukrainians across the country made their way to their cities’ main train stations. Panicked people on the platform tried to break into the carriages, mobbing the doors and beating them with their hands. When allowed to board, they folded their bodies into the compartments: Luxury sleeper carriages made for 18 would hold 150, a second-class carriage, made for 54, would carry 500. These people had left everything, possibly lost everything, and now they were packed shoulder to shoulder so tightly there was no room to sit. The largest refugee crisis in Europe since World War II had begun. For days that turned into weeks, Ukrzaliznytsia employees worked nonstop, without breaks, moving people away from this nightmare.

Trains quickly became the backbone of the country: essential to the war effort, crucial to moving people, weapons, goods and supplies, as well as providing a diplomatic avenue and an economic lifeline. As Russia began to target critical infrastructure, the job took on an added danger. Trains “running on schedule” — a catchphrase Kamyshin repeated as a mantra — became a symbol of normalcy in the most abnormal situation.

For so long Ukrzaliznytsia has been a symbol of Ukraine, its history, its colonization, its aspirations for change and its inability to attain that reality. Post-independence in 1991, the state monopoly had come to embody the morass of much of Ukraine’s attempts at post-Soviet reform — emblematic of the endemic corruption, political infighting and cronyism. In this time of existential crisis, however, Ukrzaliznytsia made its own contribution to Ukrainian resilience, reflecting the country’s unification in the face of imminent destruction.

ImageAn evacuation train arrives in Dnipro.
Credit...Adam Ferguson for The New York Times

Ukrzaliznytsia is so vast it has long been referred to as “a country within a country.” There are 230,000 employees, from those on the trains themselves (locomotive drivers, their assistants, train attendants, conductors) to everyone at the station (stationmasters, security officers, ticket sellers, luggage-storage clerks, cleaners) and then everyone behind the scenes (track inspectors, car inspectors, signal maintainers, structural engineers, electricians, electronic-equipment engineers, locomotive electricians, greasers, train dispatchers, railcar loaders, railcar mechanics, switchmen, track workers and depot attendants, without whom passenger toilets would back up). Then there are depot and workshop jobs (hostlers, repairmen, carpenters and factory workers, to name a few). Ukrzaliznytsia does its own laundry, it has its own glass factory, a carriage factory, a steel-rail rolling factory and another factory that cuts the rails to size. There are railway schools for children, vocational schools, summer camps, sanitariums and hospitals. The 15,000 miles of tracks are government-run and controlled from the center, including stations, depots and factories.

Ukraine’s passenger and freight railways are grouped into six regional branches. In the first days of the invasion, the command cell held a call every hour with the heads of the six branches to gather information using an old Soviet-era technology, a closed-circuit system called a selector. The six branch heads then held their own selector calls with subordinates to collect information. Each regional branch has an average of four directorates, and each directorate has 50 to 100 railway stations, which also held their own calls. Selector call after selector call, information made its way up to Kamyshin from all over the country.

Because many traffic controllers and safety officers live along the tracks, Ukrzaliznytsia knew how many tanks passed the border, how many helicopters were landing and how many paratroopers had arrived. Rail workers literally counted parachutes on the tracks. Kamyshin could follow the Russian military’s progress in real time based on when it passed particular stations, and he told me that he fed the information to the military.

On Feb. 25, Russia hit Ukrzaliznytsia’s reserve command center with a cruise missile, but for the most part, the network avoided large-scale damage. The Kremlin was running a limited-strike campaign and did not actively target critical rail infrastructure, like bridges and train yards, because they assumed they would quickly take control of the country and depend on the same infrastructure. Ukrainians believed that because the Russians were relying on railways, too, they could safely gather people at stations for evacuation.

The command cell quickly made two decisions. First, all passenger trains would transition to evacuation mode: They would be free, with no tickets required, and as many people as possible would be allowed to board. Second, they would run at slower speeds, which would help limit the scope of the damage if the Russians struck a train or near a track. Ukrzaliznytsia would try to preserve the life it could.

Every day, the group drafted an evacuation train schedule that went live at 9 p.m. for the next day, posting it on their website as well as their Telegram and Facebook feeds. The railway had to juggle carriage, locomotive and track capacity: If one day the stationmaster in Kharkiv predicted they would need 42,000 people evacuated, they had to find enough trains to move 42,000 people. They checked nearby stations and depots; they looked at cities where the flow of passengers had decreased and brought trains headed there back to Kharkiv. The goal was to have no one sleep on the platform in the city closest to the Russian border.

The state monopoly learned to be nimble and adapt to wartime footing. The rail-cutting factory started making tank-stopping “hedgehogs,” welding rails together into three-pronged jacks. When protests in smaller towns erupted, demanding that people be evacuated because they couldn’t get to the bigger cities, Kamyshin realized he would have to find the carriages to send trains there, too.

Credit...Adam Ferguson for The New York Times

Ukrzaliznytsia was not immune to criticism. In the chaotic first days, videos surfaced of foreigners, mostly African and Asian students, being prevented from boarding the trains. Human Rights Watch collected testimonies that “revealed a pattern” of blocking foreign students from evacuating. Attendants I spoke to said that in their experience, they had been prioritizing mothers, children and the elderly, but the testimonies and reports showed an uncomfortable reality of life in Ukraine and left a stain on an otherwise remarkable effort.

As millions of people moved west, trains were returning empty. Volunteers began asking if they could fill the carriages with humanitarian goods — boxes of medicine, food supplies, baby formula, diapers — so Ukrzaliznytsia opened the carriages for free transport of aid. Later, Ukrzaliznytsia standardized the process with the Ukrainian postal service, attaching dedicated railcars to trains. Since then, they have distributed more than 140,000 tons of food, at least 300,000 tons of cargo and carried over three million parcels of mail.

For a country that has skillfully mastered the Western media narrative — from promoting Zelensky’s famous leaked phrase “I need ammunition, not a ride” to the ubiquitous Snake Island slogan “Russian warship, go [expletive] yourself” — the railway’s triumph quickly became another public relations boon and a morale booster.

In mid-March, when the prime ministers of Poland, the Czech Republic and Slovenia visited Kyiv, they came by rail. At that time, the capital was a ghost town — its broad boulevards were empty, sandbagged and knotted with checkpoints. The city’s silence was pierced only by air-raid sirens, winding up slowly and then wailing at full volume. The citizens who remained were on edge. Kamyshin was nervous but organized the trip. It was so successful that dignitaries and celebrities — including Boris Johnson, Nancy Pelosi, Anthony Blinken, Emmanuel Macron, Justin Trudeau, Angelina Jolie, Sean Penn and Annie Leibowitz — have taken a “secret” diplomatic train, posting selfies from the luxurious carriages. Kamyshin has named it #IronDiplomacy. (Because of security concerns, however, The New York Times barred its journalists from traveling by train after the invasion.)

As the war progressed, Ukraine and Russia each used the railways to further their attacks and bolster their defenses. “Rail is really important from a logistics position,” says Rob Lee, senior fellow in the Foreign Policy Research Institute’s Eurasia Program. Russia’s reliance on artillery barrages makes the railways particularly valuable. “For a lot of the fighting, it was often a matter of which side was firing more artillery rounds a day. Quantity really mattered a lot, and that comes down to logistics, not just how many rounds can each type of artillery fire a day, but how much artillery can you get to each position — what is the logistics network like?”

In April, when Russia abandoned hope of a seamless takeover, the Kremlin changed course and began targeting critical infrastructure: electrical substations, fuel depots, train stations and railway bridges. When Russian missiles hit five electrical substations in the west of the country, 19 trains were temporarily suspended. In June, missiles struck routes in the Carpathian Mountains. Fifteen trains were delayed for up to 10 hours.

As Ukraine liberated occupied territory in the Kharkiv and Donbas regions over the summer and fall, the rails again became crucial strategic prizes: Each recaptured junction made it harder for Russia to resupply its remaining forces. “All you have to do is look at a map, the problems are very obvious,” says Michael Kofman, director of the Russia Studies Program at the Center for Naval Analyses. “Access to supplies by rail made a real difference in the Russian ability to sustain offensive operations.”

In October, an explosion that hit a train carrying fuel caused the partial collapse of the Kerch Strait Bridge linking the Crimean Peninsula and Russia. (Ukraine has not publicly claimed credit for the strike.) “This has a direct effect on Russia’s ability to move forces or supplies back and forth across the Kerch Strait Bridge, and that line kept supplying the bulk of Russian force in the south,” Kofman says.

Credit...Adam Ferguson for The New York Times

Whenever the Ukrainian military pushed Russians out of occupied towns and villages, Ukrzaliznytsia was never far behind. Workers immediately began trying to re-establish the network even when there was still active combat. “We have a rule: Our tanks go in first, followed by our trains,” Kamyshin told me. “Once our troops reclaim our territory, our job is to restore rail service there as quickly as possible.”

Unrelenting assaults had forced Ukrzaliznytsia to work under fire and in record speed. Repairs that would have taken a year took weeks or months. The Kyiv School of Economics estimated that by mid-September, Russians had damaged $4.3 billion in railway-station infrastructure and rolling stock.

Across the north and east, Ukrzaliznytsia had restored service to more than a dozen liberated stations since the start of the invasion. In early November, they brought passengers to Kupyansk in the Kharkiv region a month after it was freed. The important railroad junction was one of the first cities to be overrun in the invasion. Occupation authorities had attempted to introduce Russian passports and changes in school curriculums. Because the Russians blew up the bridge connecting two sides of the city as they fled, the first passengers to return disembarked the train and crossed the river by pontoon.

“When we return passenger traffic, people can move easily and we have an opportunity to supply humanitarian aid there on a large scale — it would take a long time to bring it in any other way,” Kamyshin said. “It is also an opportunity to bring in cargo traffic, and this is the economy, the lifeblood, of any war.” Kamyshin does not comment on the use of trains for military transport, but analysts believe Ukraine also relies heavily on the railway network to resupply its own troops.

Attacks have killed scores of civilians. In April, a missile strike on a crowded platform in eastern Kramatorsk station killed 60 and wounded 111, and a rocket attack on Ukraine’s Independence Day on Aug. 24 on a train station in Chaplyne in eastern Ukraine killed 25 and wounded dozens more.

Ukrzaliznytsia employees have become heroes: On March 20, the prime minister presented 20 railway workers with awards for “courage and heroism” under wartime conditions. Twenty-four hours later, Kamyshin ran into one of them, back at work in the Kharkiv depot, fixing the electricity grid under shelling, still wearing the same sweater. By Nov. 1, 19 Ukrzaliznytsia workers had been killed while on the job. Thirty-eight had been injured.

Ukrzaliznytsia’s Telegram channel, with 300,000 subscribers, popularized the hashtag #IronPeople. “The moment when you look at a photo of the G7 summit and realize eight out of 10 have already traveled by Ukrzaliznytsia trains this year, some even twice, and some even three times,” Kamyshin posted on Telegram.

In recent weeks, the Kremlin has gone after Ukraine’s electrical grid, plunging Ukraine into rolling blackouts. “Half of our traffic is electric trains and electric locomotives, so when they hit energy infrastructure, we also suffer, but we’ve learned to deal with it, to repair it promptly and keep going,” Kamyshin told me. “We’ve prepared our stations so that when the power, water or anything else in the city and in the regions goes out, we can continue to operate. The station will always be light and always be warm.”

Credit...Adam Ferguson for The New York Times

The first passenger train to arrive in Ukraine came, perhaps fittingly, from the West: A line linking Lviv to Krakow was completed in 1861. Western Ukraine, commonly called Galicia, was controlled by the Hapsburg empire, while central and eastern Ukraine belonged to the Russian empire. Russia’s humiliating defeat in the Crimean War propelled it to launch an ambitious reform and industrialization effort, particularly regarding the rail system. In 1865, the Russian empire completed its first railroad in present day Ukraine, connecting the port city Odesa to the southwestern agrarian town Balta to transfer grain from the heartland for export to Europe. At the time, Ukraine accounted for 75 percent of all exports from the Russian empire.

“The railway in Ukraine before 1917 served almost exclusively Russian imperial — one can say colonial — interest, because the way railways were built and where lines actually led was a pretty colonialist enterprise,” Serhiy Bilenky, research associate at the Canadian Institute of Ukrainian Studies, says. “Resources were brought by train from Ukraine to Russia. Russia transported ready-made goods and a work force to Ukraine. Ukraine did not produce almost any ready-made goods or consumer goods.”

By 1914, there were more than 10,000 miles of track crisscrossing Ukraine. During World War I, empires battled along train lines across the continent, destroying and rebuilding stations in Ukraine as they came and went. When Germany first occupied Kyiv in 1918, it hired local women to wash the main passenger station, to make a point about how backward and dirty the Russian empire was.

During World War II, the Wehrmacht marched through Ukraine with such ferocious speed that it was practically impossible to flee. In the west, Lviv’s central station would change hands among the Poles, the Russians, the Nazis, back to the Russians, back to the Nazis again — and each time, the occupying army destroyed and rebuilt part of the rail system. In Kyiv and the east, trains were used for evacuation, but mostly for Soviet officials, those who worked on strategic enterprises and their immediate families. Unlike in the rest of Europe, the Nazis did not rely on trains to transport Jews in Ukraine to death camps. With the help of Ukrainian collaborators, they were shot close to their homes, often referred to as “holocaust by bullet.”

When the Red Army retook Ukraine territory, the Kremlin utilized trains to reimpose Moscow’s authority. Stalin used trains for ethnic cleansing — the most infamous case was the Crimean Tatars in 1944, with roughly 200,000 deported over three days in cattle cars to Central Asia because they had “betrayed the motherland.” In 1945, Western Ukraine, which had never been under Moscow’s control before World War II, was officially incorporated into the Ukrainian Soviet Socialist Republic. In 1954, Crimea was added to the republic, solidifying the country’s borders.

At its height, the U.S.S.R.’s railroad network totaled 91,600 miles. It was among the largest in the world. It had its own ministry with as many as four million employees. Train attendants memorized all routes from Vladivostok to Tbilisi. A railway job was prestigious, not just because of the relatively higher salaries but because of the benefits that came with it. Generations went to work on the rails and proudly referred to themselves as “dynasties.” Many married one another and sent their children to railway technical and trade schools. In a Soviet society corrupted by nepotism and performative party loyalty, many believed it was the kind of career in which a person who applied themselves could truly advance.

Russification, already predominant in urban areas of the center and east of Ukraine during the Russian empire, spread along the railway lines as more regions were integrated into the Soviet structure. Yet, the trains also inadvertently created space for the survival of a Ukrainian identity. As young people flocked to the cities for Soviet education in Russian, train travel was cheap enough that those same students often went home on the weekends to the villages where their parents lived and where Ukrainian was spoken.

“Railways were the way to live in two worlds, one which was Sovietized and the other was not Sovietized,” Yaroslav Hrytsak, professor of history at the Ukrainian Catholic University, told me. “It was extremely important for building this kind of identity, not anti-Soviet, but non-Soviet identity — preserving this non-Soviet identity and memories.”

Credit...Adam Ferguson for The New York Times

After Ukraine’s independence in 1991, Kyiv painted green Soviet carriages blue and redesigned the uniforms and epaulets, but little else changed. Ukrzaliznytsia’s six regional branches still don’t bear Ukrainian names or orientations — their directions only make sense when viewed from Moscow: The “southern branch” is actually in the center of Ukraine, while the “southwestern branch” is geographically in the north of the country. Ukrzaliznytsia was restructured but never privatized, the railroad degraded, and the chief executive position became a political post, given out to curry oligarch favor. “It was so common to choose someone who had no idea how railways work, people even started to joke about it,” Mykola Kopylov, editor in chief of Rail Insider, a Ukrainian industry publication, told me.

In 2000, Heorhiy Kirpa was appointed head of Ukrzaliznytsia. His bronze bust still adorns the outer wall of Ukrzaliznytsia headquarters in downtown Kyiv. Under Kirpa, Ukrzaliznytsia embarked on an ambitious reconstruction program, renovating dozens of railway stations while maintaining travel services. He started the first express trains, added more electric trams and put down the country’s first fiber-optic cables along the tracks. He supposedly got kickbacks on the procurement of new equipment — and he bought a lot of new equipment. (Did the country’s national railway really need to buy batteries for the Ukrainian submarine Zaporizhzhia?) A staunch supporter of Viktor Yanukovych, the Kremlin-favored politician from Eastern Ukraine whose theft of the 2004 presidential election set off the Orange Revolution, Kirpa died of mysterious circumstances that year. His death was officially ruled a suicide, but many were skeptical. Since his reign, few have held the post for more than a year.

In 2014, Ukrainians staged what became known as the Euromaidan protests, toppling Yanukovych after he bowed to Russian pressure and halted plans for an economic alignment agreement with the European Union. Fueled by Russian propaganda — as well as decades of cynical Ukrainian government policy that drummed up votes on the back of historic regional grievances between East and West and manufactured language divisions between native Russian and Ukrainian speakers — separatists in the east of the country took over cities in the Donetsk and Luhansk regions. Russian soldiers without insignia, meanwhile, stormed Crimea.

At the time, there were no organized evacuation trains for citizens, and people in the Donbas had to make their own way to Ukrainian-controlled territory. Slowly, train service between the Crimea, Donetsk and Luhansk and Ukraine just stopped. “This happened as the infrastructure collapsed,” Oleksandr Nosulko, the director of the Donetsk branch, told me. “These were the trains that never returned.”

Credit...Adam Ferguson for The New York Times

Before Russia annexed Crimea, Ukraine had never really developed a civic identity. The U.S.S.R. had designated ethnicities on internal passports — “Ukrainian” “Russian” and “Jewish” to name a few — and since independence, Kyiv had done little to integrate the communities. To be Ukrainian from the country rather than belonging to the ethnic nation was a concept that only slightly took root after the Euromaidan.

Trains had been one of the few places where regional and ethnic stereotypes were challenged, where identity and civic understanding were formed. Ukraine is one of the poorest countries in Europe. Most Ukrainians still travel around by rail, which is old and slow, leaving plenty of time to chat or drink with your neighbor. “Ukrzaliznytsia, it’s like a social glue,” Volodymyr Kulyk, head research fellow at the Institute of Political and Ethnic Studies at the National Academy of Sciences of Ukraine, told me. “It’s really something that connects different parts of Ukraine, and brings together people with different backgrounds, different languages with different financial means. People need to know people from other parts of the country to feel they have something in common with them.”

In April 2019, Zelensky was elected on promises to rid the country of corruption. In the years that followed, Ukrzaliznytsia chief executives came and went. In 2021, Kamyshin took the helm, and in November and December of that year, Ukrzaliznytsia carried a record amount of freight cargo and started running a profit again. It bought new carriages, wagons and locomotives and opened five passenger-train lines in smaller stations. Kamyshin had grand plans to continue modernization, to start electric high-speed trams and connect more of the country.

Analysts I spoke to suggested that it was too early to say if Kamyshin would have succeeded or if this was yet another attempt at reform that would have been thwarted by the usual dark forces of Ukraine’s turbulent politics and oligarch-aligned economy. Zelensky was elected by the highest-ever percentage of votes, but in the days before the invasion, his approval rating was lower than it had ever been. As observers waited for the decrepit network to fall apart, its capabilities surprised even its most virulent critics. “I’m quite impressed that the railroads have functioned so well,” Anders Aslund, a Swedish economist who served on Ukrzaliznytsia’s supervisory board for two years before leaving in 2020 in protest of the lack of reforms, told me. “This is the advantage of backwardness.”

In some ways, it was the state monopoly’s autocratic Soviet legacy that led to its unexpected wartime success. The things Kamyshin had been asked to change became an advantage. Ukraine had too many rail lines, making it possible to ferry goods and people on varying lines and reroute the trains quickly in the event of an attack. Because Ukrzaliznytsia had only electrified part of its rails, diesel-powered trains could still run when electrical substations were attacked. (Electrified rails are considered faster, cheaper and more environmentally sustainable, but diesel locomotives are more reliable in war.) Reformers complained there were far too many workers, but that also meant there was a surplus of engineers familiar with making repairs in tight economic conditions. Employees, used to top-down command structures, reported for work.

Credit...Adam Ferguson for The New York Times

I was visiting my parents in Miami when the invasion started. We spent my entire weeklong trip glued to the television. My mother, like my grandmother and her grandmother before her, was born within the borders of present-day Ukraine. None had an easy life there. We watched with a sense of powerlessness — a mix of horror, guilt, and an internal reckoning about post-Soviet identity and our family’s place in that nation’s history that we had been struggling with for so long. As the TV analysts proclaimed that much of Ukraine would be overrun in 72 hours, we surprised one another with our tears. Seeing the scenes at the stations, the horror, the inhumane crush of people trying to survive and those working around the clock to save them, I began to think about Ukraine’s railroad.

Weeks before the Nazis marched into Kyiv, my 23-year-old grandmother was sneaked onto an evacuation train. Everyone else in my family who stayed in Kyiv was killed: either marched to Babyn Yar or rounded up by their neighbors and shot in the courtyard of their own building. I grew up with the knowledge that I was alive because of this small fortune — a story my family tells over and over again. I know how valuable it is to evacuate one life. How that life begets more lives, how Ukrzaliznytsia employees were saving generations, people they would never meet.

Earlier this year, I spent five weeks driving around the country talking to Ukrzaliznytsia workers and volunteers in train stations in six cities. I believed the rail network perfectly encapsulated much of what I had been reporting on and off in Ukraine for a decade — all the things that had been right and wrong in the country even before the invasion. Afterward, the same network came to symbolize the remarkable aspects of Ukrainian devotion to their country and their determination to resist Russian attacks. I wanted to see life as it was lived on the rail and to witness the community it created in wartime in order to answer a question I have been asking for a long time: What does it mean to be Ukrainian? How many years does it take to shed the U.S.S.R., like a snake molting its skin?

The invasion revealed a new kind of nationalism. The same politicians, highly placed civil servants and businessmen who previously thwarted aspirations of the newly democratic Ukrainian state were now fighting for their homeland. Many Ukrainians themselves were surprised by how quickly the country united. Some believed this unity was preordained. “We fight each other every day,” Yaroslav Krysko, a volunteer I met in Dnipro, told me, “but when there’s a problem, we band together, and then as soon as it’s over, we will go right back to fighting each other again.”

All of Ukraine’s faults had been forgotten in the attacks — corruption, regional divisions, political infighting, sexism. How much of it would finally be put to rest by this war? How much of it was waiting somewhere, just out of view? Already there were whispers and accusations — about those who collaborated with Russian occupiers, those who fled when they should have stayed to fight.

The trains bred their own culture. There was a predictable pattern to riding the rails: People got on, changed into their train clothes, ate food they had packed and slept at basically the same time, in easy consensus. On the train and in stations, people shared what little information they had. For that moment, they were together, constructing their own understandings of this war from a small tin tube of safety amid the chaos outside. Ukraine’s trains had always been slow, rocking people into a kind of warm, languid hypnosis. Home, after so many evacuations and deaths, had taken on a new meaning.

Credit...Adam Ferguson for The New York Times

From Kyiv, it is roughly a six-hour train ride east to Kharkiv, Ukraine’s second-largest city, which had borne the brunt of the initial invasion. And though Russia had been repelled from the center, at the end of May when I visited, the Russian Army continued to terrorize the population from just outside city limits, shooting rockets into leafy green parks in the center of town, lobbing mortar shells into residential buildings. Air-raid sirens blared constantly. The residents who remained lived in a perpetual twilight of war.

Behind the grand, marbled Kharkiv train station, replete with murals of Soviet patriotism and vitality, there was a black, graffiti-covered decommissioned dining carriage serving as a lunchroom for all Ukrzaliznytsia employees who remained in the embattled city despite the Russian onslaught. Every weekday at noon, at the neon-green counter, three women who previously worked in a cafe in the station’s depot before it was shelled started ladling out a multicourse lunch — soup, a main with a side, along with compote, a fruit drink. Nearly a hundred Ukrzaliznytsia employees trooped in over the next two hours, picked up a tray, sat at a gray upholstered seat with a tray table and bantered about the mysterious pink sauce offered on the counter.

In the next carriage, an ordinary second-class, blue-colored overnight sleeper, there were nine passenger compartments where Ukrzaliznytsia employees who lost their homes now lived — train attendants, a bogie repairman, a battery technician, a store woman, a handyman, a train-car inspector, a technical-security foreman and a married couple of equippers showed just how many people it took to make a railway work.

Halyna Zhuravska, a train attendant, was the first to move into the carriage. Her train was standing in Kyiv station when the invasion began. Her town, Chuhuiv, 20 miles outside Kharkiv, was bombarded immediately, so she worked without a break for six weeks to evacuate people. “I didn’t have anywhere to go anyway,” she told me. “At least I could help people.”

When it was clear she needed a home and some time off work, she was offered a place in the wagon. She chose a compartment far from the bathroom and built her own hanging light as decoration. She preferred to listen to audiobooks rather than socialize. Halyna graduated from Kharkiv National University with a degree in philology, Ukrainian language and literature. She took a summer job on the rails and dreamed of a life of adventure. At the time, she could ride free to any part of the Soviet Union — Kaliningrad, Vladivostok, Belarus, Crimea, Sochi, the Caucasus. “I loved it, it was like romance,” she told me. She built her own house, raised her children and kept to herself and her books. Now, she sent money to her daughter and grandson who fled to Norway when the invasion began.

In Compartment 3, Liudmyla, a store woman, hosted her nephew and father — the family was debating whether to travel back to Slatyne, a town 18 miles north toward the Russian border, to collect their things and patch up the roof. Oleksii, a battery repairman in Compartment 4, who had lived a few blocks away in Slatyne, thought they were insane for trying. He had given up on going back.

I asked Halyna and Oleksii what they did on their days off. Both told me they preferred to stay in the carriage, though they all knew its thin walls offered little protection from any attack. “I don’t want to roam the streets or be in open spaces,” Oleksii said. “I don’t know, maybe I already have some kind of phobia, but I’d rather just stay here. I’ll plug the phone into the phone charger, I’ll watch some TV series. That’s better.” At night, many of them sat outside the carriage on a little wooden bench, chatting and smoking. They had planted onions in a plastic tub, tended to them and watched the green shoots grow. In the dark, every night, they could see rockets and missiles streaking the sky.

Credit...Adam Ferguson for The New York Times

Yet, despite the risks in Kharkiv and towns close to the Russian border, residents were returning as the Ukrainian military pushed the Russians back (5,000 people per day when I was there). At the station, many waited on the platform with flowers. I watched an intercity train pull up from Kyiv, and a pair of young men fell into each other’s arms, the returnee, Oleh, in tears. Oleh was 19, tall, lanky and covered in tattoos. He had come back from the relative safety of western Ukraine because he couldn’t be away any longer. He set down a plastic picnic basket and communed with his cat.

“That’s it, we are home! Home!” Oleh proclaimed, brushing back his hair and rubbing his eyes. I asked what he would do first.

“I’m going to hug everything,” he said. “I just want to come home and hug everything.”

The Pokrovsk junction in the Donbas region — with a locomotive depot, railway-car depot, power-supply station, track-repair station and signal-communication station — had been hit by at least two airstrikes. The first time the Russians damaged the tracks; the second time, the tracks and catenary wires. Another night, a cluster bomb exploded above the sorting station. Emergency services did their best to clear the area, but because it was snowing, they missed a mine. When the snow melted, one of the rail repairmen stepped on it and was struck with shrapnel; he later died from blood loss.

Before Feb. 24, Dmytro Vakulenko, the junction stationmaster, was in charge of 360 workers. After the attacks, there were 80. “Our workers are also people, and after the railways as well as the station itself were hit by the rockets, they evacuated together with their families,” he said.

When we met in May, Pokrovsk was only 20 miles from the front lines. It was the first stop of the only free evacuation train going west. Most of the beige-tiled station’s windows were boarded up. The ones that remained were sandbagged, but the glass still danced with the faint booms of shelling in the distance. Ukrzaliznytsia employees had started to trickle back even as the frontline pushed closer toward them.

When Dmytro became stationmaster at 26, he was one of the youngest in the country. His grandfather worked on railcar assembly, his grandmother was a signalwoman, his father worked the rails and so does his wife. The dread of the frontline approaching was palpable in Pokrovsk, but for Dmytro, it seemed he would lose not just his work but the way of life that defined him and his family. He couldn’t imagine leaving. “I am scared to lose the station,” he told me. “I am scared to realize it’s under occupation or destroyed. I must have walked every part of it a thousand times.”

No one in Donetsk Oblast had to look far to see their nightmare reflected back to them. Svitlana Kravtsova had been the head of the passenger terminal in Popasna — a smaller town 67 miles away — for 20 years. As fighting intensified, the last passenger train left the station on March 2, but Svitlana remained. Even during heavy street fighting, she walked the seven minutes from her house to survey the station and file a daily damage report. There were times when it was too dangerous to go outside, but on the days she made it to the station, Svitlana and some of her female colleagues tried to salvage what they could.

“The things that we could save, we saved,” she told me over tea with Dmytro in her temporary office on the second floor of the Pokrovsk passenger station. “Can you imagine our houseplants, plants this big” — she spread her arms wide — “freezing? There is no way we would leave them there.”

“This is certainly women’s logic,” Dmytro interrupted. They laughed.

“This is exactly what we were doing, Dmytro Volodymyrovych,” she addressed him respectfully, with his patronymic. “We are women, so we saved what we could and hid what we could not save. But we stopped when we realized it was not safe and basically not possible. The conditions were inhumane. I made my final decision to leave when I came to see the station and realized that we won’t be able to restore the station by ourselves. We needed heavy machinery and peace. To do that with the ongoing 24/7 attacks it was impossible. After that, I left.”

By the time we met, she had been officially transferred to a post at Pokrovsk. Popasna station is cratered with mortar fire. Her father’s and her relatives’ houses are all gone.

“We love our jobs, but we are also scared like other people are,” Dmytro tried to explain. “Only the stupid ones are not scared. We both clearly understand that any minute can be fatal, but we still have to do our job.

“It is not an easy thing to leave everything behind and start doing something else you do not have any experience in,” he continued. “I do not want all of my hard work to become useless. I think Svitlana Borysivna would say the same.”

“I cannot imagine my life without passengers,” Svitlana echoed. “And he can’t live without freight cars.”

Across the Ukrzaliznytsia, rail workers were incredulous when I brought up fleeing. Why would they leave when their country needed them to stay? No one wanted to be called brave outright; they were all just doing their jobs. Though they may have been initially drawn to the work for different reasons — family history, a sense of adventure or sheer economics — the railway had become a kind of religion. The pay had not kept up with the times and the job had lost prestige and many of its previous benefits, but this war had made the Ukrzaliznytsia workers proud of being called #IronPeople.

After the April attack on Kramatorsk station, Ukrzaliznytsia decided Pokrovsk was the safest place in Donbas to gather a large group of people for evacuation. The company started pulling brigades from different bases to work the evacuation route.

Credit...Adam Ferguson for The New York Times

In the early days of the invasion, Tetiana Vislohuzova, a rules examiner in the Dnipro office, agreed to return to working as a director of an evacuation train as soon as she was asked. She left the relative safety of the main office for the danger of the rails. “The first time I went on an emergency train, I said, ‘Give me a bulletproof vest, a helmet, just in case,’” she told me. “They smiled and said, ‘What helmet, what bulletproof vest?’”

Tetiana also worked on a medical train taking the wounded from the Kramatorsk station attack. In a partnership between Ukrzaliznytsia and Doctors Without Borders, two trains had been retrofitted for medical use, one as a mobile intensive-care unit. Doors had been widened for stretchers and compartments fitted with equipment, staffed by doctors and Ukrzaliznytsia attendants in shifts. The train’s routes aren’t publicized because of their proximity to the frontline.

Nothing prepared Tetiana for the violence she saw on that route. She helped a mother with a baby whose arm was torn off. Then there was Yana, an 11-year-old who weighed only 60 pounds. The staff carried her into the train in their arms. A rocket had taken her legs. When Tetiana walked into their compartment, she heard Yana’s mother trying to calm her.

“Yanochka, everything will be OK! Everything will be done for you! They will fix your legs, the doctor says they’ll get you heels and you will dance!”

Tetiana turned to look at Yana’s mother, wanting to see this strong woman with such a confident voice. She looked down and saw the attack had taken one of the mother’s legs too.

Credit...Adam Ferguson for The New York Times

As Russia loses territory, there is a persistent anxiety that Putin will do something to offset his military’s initial failings. People fear an escalation. Anything can happen — a chemical or nuclear attack. Across the country, the train system has taken on roles it never has before — feeding, sheltering and providing trauma counseling and first aid for the masses. Ukrzaliznytsia continues to rely on the citizens who rally around it.

In Dnipro, the second stop of the evacuation train, 100 miles west of Pokrovsk, through the doors of a former shopping plaza, catty-cornered to the Dnipro passenger-train station, the Mother and Child Center accepted evacuating mothers with children and invalids. The center sprang up spontaneously in March. Volunteers, seeing the mothers and children waiting in lines outside the station, thought there should be a place for them to rest. Coordinating with the mayor and the stationmaster, they developed a system under which those needing assistance could be taken straight from the center to the train platform to pre-board, avoiding the crowds at the station. They could stay up to two nights.

Dnipro was no stranger to wartime chaos and evacuations. The Russian-speaking eastern city of one million had long been a large railroad junction, sitting between the Donetsk coal basin and the Kryvyi Rih iron-ore basin. During the Soviet era, it was home to a secret ballistic-missile plant and was closed to foreigners until 1987. In 2014, the city was expected to be the next in line to fall to separatists after Donetsk, but instead, it remained resoundingly committed to being part of Ukraine. As a result of being the closest city to the newly declared separatist republics, internally displaced Ukrainians streamed into Dnipro.

Credit...Adam Ferguson for The New York Times

This iteration of the war was no different. The city was a funnel for citizens fleeing to areas that remained under Ukrainian control. In the shopping mall, the volunteers had taken over the ground floor. Roughly 80 of them worked in three shifts. Evacuees arrived at all hours. Initially, there were around 2,000 every day; at the end of May, there were about 200. Food was brought twice a day by World Central Kitchen. Hot meals — soup, porridge and meat — were available any time. Boxes of boiled eggs, sandwiches and some vegetables were given out for breakfast or taken on the train. People were transported to the center by volunteer organizations, often church groups or other nongovernmental groups, or hired drivers. They came in vans, cars or buses. (Numbers surged again in June and have fluctuated since, depending on the course of the war.)

“People have spent a long time in basements before the evacuation and have not eaten hot food for a long time,” Odarka Bila, director of the department of youth policy and national-patriotic education for the Dnipro City Council, told me as she showed me around. There was a separate room for mothers with babies to rest, with changing tables, baby food, formula and diapers of varying sizes. Everything was free. The center distributed potties and strollers from a stockpile of donations.

Credit...Adam Ferguson for The New York Times

Along a wall, there was a section for people to pick up secondhand clothes and shoes. Cots lined two rooms, and Ukrzaliznytsia-branded linens were changed daily. (Through a partnership, the railway launders the center’s linens.) At the back of the sleeping room, there was a small exhibition of photographs and cheerful children’s drawings next to a large play area staffed with volunteers. Twice a day, preschool teachers came to do crafts. Toys lined the walls, and children were allowed to take what they wanted.

“In the beginning, it was very difficult, because when the weather was bad, when it rained, people came just in slippers and walked through puddles, practically barefoot,” Odarka said. “There are a lot of wounded people coming in, so we also asked for crutches. It is not from foundations, ordinary people brought them to us, and we give them to those who need them. Here we have wheelchairs.

“There are a lot of people who do not walk well, who do not walk at all,” she continued. “We have padded stretchers; before we used to carry people on blankets.”

Every day around 6 p.m., Yaroslav Krysko, the deputy director of the department of ecological policy for the Dnipro City Council, began walking between the cots in the darkened room, shouting: “I’m making a list for the evacuation train! It stops in Ternopil! Vinnytsia! Khmelnytskyi! Give me one name per family. We are gathering at the entrance at 7:20!”

Some gave their names eagerly, others appeared wary. They approached with all kinds of questions; most wondered where they should go. Yarolsav referred them to a government website called You Are Welcome Here that tracked available housing around the country. But with 6.2 million internally displaced people in all of Ukraine — nearly a fifth of the country, the largest human displacement in Europe today — the cities were full, though there was space in the countryside. What will we do for work there? No one could answer.

Credit...Adam Ferguson for The New York Times

Each night at the Dnipro train station, on Platform 1, the same volunteers follow the same script: Yaroslav shouted for everyone to stand to the side, to wait, to walk, to stand to the side, to wait, to walk, to board, to stop pushing.

One night, we walked Yevheniya, a blind older woman from Bakhmut, to a train west. I watched as Dave Young, a British volunteer who had been living in Ukraine for 16 years, brought her to the center the day before. Dave volunteered with a group of drivers who slept in Dnipro and drove east every day to collect people who wanted to evacuate. He told me that Yevheniya had what drivers called the “Bakhmut burn” — the smell of those who didn’t have water to bathe and lived in smoke from bombardments — but was in relatively good spirits. The volunteer group gave him locations for pickups, but sometimes those fell through and he just drove around Donbas towns asking if anyone needed a ride out. Someone in Bakhmut had directed him to Yevheniya. He placed her in a van and then loaded three other evacuees: an intellectually disabled young woman, her grandmother and her drunken brother. (Dave later lost an eye on another evacuation when his car came under attack. He is still driving.)

Yevheniya spent the night in the center waiting for a train that would take her to a town in central Ukraine, where she had friends. Yaroslav held one arm, a teacher named Tanya held the other. Step by step they walked her to the platform, describing every dip in the pavement, every stair. They spoke about the champagne factory that had been destroyed in Bakhmut, how beautiful it had been, how sweet Soviet wine was. Tanya suggested Yevheniya try to reach Germany, where she thought they could perform an operation to restore her sight. Yevheniya said she was fine as she was.

It started to drizzle, and we all walked in the mist. They led her into the carriage, helped her sit on the bunk that would be hers. They stored her bag, arranged her bedding and took her photo to show Dave she had made it safely.

“We have no right to show our emotions,” Yaroslav told me. “We have to support people. Be like a wall. And first of all, show these people that they are under our protection, they are safe and we are doing everything we can to make them feel safe. That is our main task.”

As we walked back, I thought about Yevheniya’s safety, about the work, all the volunteers and Ukrzaliznytsia employees that overlapped with one another, the energy that went into saving just one life.

Sarah A. Topol is a contributing writer for the magazine. Her work has won a National Magazine Award as well as an Overseas Press Club Award, among others. She previously wrote about the pro-democracy movement in Belarus. Adam Ferguson is an Australian photographer based in New York. He is currently working on two monographs — a war diary about his time in Afghanistan and a contemporary portrait of Australia’s colonial legacy.