HONG KONG—As floodwaters surged into a stalled subway train beneath the Chinese city of Zhengzhou, Pure Li hurriedly tapped out farewell messages to a close friend on her smartphone. “I may not be able to get out,” she wrote.

The 26-year-old engineer was one of more than 500 passengers trapped during the evening rush hour Tuesday, as torrential rains pummeled the central province of Henan. A dozen people wouldn’t make it out alive, authorities say, and at least two were still missing as of Saturday morning.

Desperate images from commuters surrounded by roiling water went viral on Chinese social media this week, striking a nerve in a country that has vastly expanded its subway systems, and suffered a series of serious underground flooding incidents that have raised safety alarms.

On Thursday, China’s Ministry of Transportation ordered subway systems nationwide to re-examine and improve contingency plans for extreme weather. Authorities in Zhengzhou, Henan’s capital city, and Zhengzhou Metro Group, the state-owned subway company, didn’t respond to requests for comment.

As rain fell in Zhengzhou on Tuesday, turning roads into swiftly flowing rivers and wreaking hundreds of millions of dollars of damage, according to state media, water began to pool in a train yard, the metro company said in a statement. It then broke through a wall and flowed into a tunnel.

A flooded road in Zhengzhou, China, on Friday.

A flooded road in Zhengzhou, China, on Friday.

Photo: aly song/Reuters

Ms. Li was heading home at about 5:45 p.m. local time that day when her train came to an unexpected stop a few hundred yards short of Shakou Road Station in downtown Zhengzhou. The train started to reverse, but lurched to a stop with a piercing screech. Sparks flew up from the tracks.

Soon after, water started to seep into Ms. Li’s car and the train began to tilt to the side.

A little after 6 p.m., the train conductor started urging passengers to move to the front of the train, where they could leap over the torrent of water onto a walkway on the side of the tunnel that would lead them to the station’s platform.

A number of passengers made their way onto the catwalk before the current grew stronger and it became too dangerous. One group went through the door on the other side of the train and tried to escape by grabbing a cable strung along the tunnel wall and stepping along pipelines attached below.

One of them, Zou Deqiang, slipped onto the tracks and was swept away in a torrent of water in front of a colleague, who continued clinging to the cables and was later rescued, according to Jane Li, owner of the Shanghai-based software company where they worked. Mr. Zou remained missing on Saturday.

A submerged subway car following torrential rains in Zhengzhou, China.

A submerged subway car following torrential rains in Zhengzhou, China.

Photo: handout/Agence France-Presse/Getty Images

Ms. Li, the engineer who was on the train, said she was nearing the front when the doors closed, so she didn’t see the drama.

As more water flowed into the cars, Ms. Li, who had been communicating with a friend through the messaging app WeChat, typed out a quick text: “Screwed.”

By 7 p.m., water had reached the ceiling of the cars toward the rear of the train, which had been heading up a slight incline into the station.

The slope design was used here and other parts of the Zhengzhou metro system to make it more energy-efficient for trains to enter and exit stations, according to local media and trade publications. In this instance, it allowed water to fill the tunnel.

The water continued to rise inside Ms. Li’s car, reaching her shoulders. Children and some shorter adults climbed onto the seats. Several passengers pulled down face masks and started making calls to police, firefighters, friends and family.

Soon the lights inside the train went out and the ventilation system shut down. Dim emergency lights were all that kept darkness at bay. Some passengers began pressing their faces to cracks between the doors in an effort to find fresh air. Others tried to get close to ventilation holes in the ceiling.

Ms. Li spoke to her cousin at 7:12 p.m., telling him not to tell her mother that she was trapped. “Only tell her if you cannot reach me later,” she said.

Water rose to her neck. Ms. Li texted the password to her WeChat account to her friend so that someone would be able to access her data if she died.

SHARE YOUR THOUGHTS

How should world governments protect their infrastructure in the age of climate change? Join the conversation below.

“What are you doing?!” her friend replied in panic and told her rescuers had been called.

“Go see my mom for me sometimes,” Ms. Li typed. Moments later, she heard a woman elsewhere in the car tell her child to draw close, saying, “Come here baby. Let mom give you a hug.”

Fearful that they would run out of air, passengers decided it was worth the risk to break a window. A man in Ms. Li’s car grabbed a fire extinguisher from beneath the seats and began hammering at the glass.

Powder exploded from the extinguisher onto the faces of passengers nearby. People took turns smashing at the window until a blast of foul-smelling air rushed in.

By the time they broke through, the water level outside the train had begun to drop. Several people standing next to Ms. Li climbed out of the hole in the window and into the tunnel, but she decided to remain.

At 8:30 p.m., rescuers arrived outside the train. It took them an hour to crack open the doors. Ms. Li joined others in walking along the narrow walkway to safety. As she exited the subway, she saw people sitting on the stairs, eyes scanning the mass of emerging passengers for their loved ones.

Soaked and exhausted, Ms. Li fretted about getting home. With the city in the grip of disaster, walking through water-filled streets was the only option, but she worried she might fall into an unseen fissure. Instead, she went to stay with a friend who lived nearby.

People made their way through floodwaters in Zhengzhou, China, on Friday.

People made their way through floodwaters in Zhengzhou, China, on Friday.

Photo: aly song/Reuters

In the days that followed, the incident sparked questions among residents and internet users about whether climate change would produce similar events in the future, and whether the country was prepared for the challenge.

Chinese meteorologists attributed the torrential rains in Henan in part to Typhoon In-fa, which they said pushed an unusual amount of water vapor into the mountains surrounding Zhengzhou.

While Chinese authorities haven’t drawn a direct connection between climate change and the Zhengzhou floods, Liguang Wu, a professor of atmospheric and oceanic sciences at Fudan University, said global warming has been shown to increase precipitation from typhoons. Dr. William K.M. Lau, a senior researcher at University of Maryland, went a step further, saying the inundation of Zhengzhou is “consistent with the concept of more extreme weather events under greenhouse warming.”

On Saturday, police guarded entrances to the subway station near where the train had been flooded, shooing away journalists and onlookers. The family members of passengers who had gone missing and weren’t counted among the dozen killed gathered outside Exit C of Shakou Road station, waiting anxiously for news as recovery crews pumped water out of the station for a second day in a row.

Residents had placed flowers at another exit in a small memorial to those who had died. “May the departed rest in peace, and the survivors stay strong,” read one note attached to a bouquet of white chrysanthemums.

Ms. Li, reflecting on her ordeal, thanked the passengers who assisted others and said she felt lucky.

“I don’t know if someone did something to stop the water from rising further, or God had mercy,” she said.

People waded through floodwaters near residential buildings in Zhengzhou, China, on Friday.

People waded through floodwaters near residential buildings in Zhengzhou, China, on Friday.

Photo: aly song/Reuters

Write to Wenxin Fan at Wenxin.Fan@wsj.com