Photo: Metropolitan Transportation Authority / Patrick Cashin

This morning, temperatures dropped, vast parts of the region remained without power, and New Jersey commuter lines were in a stranglehold. But there was one major, if improbable, sign of hope: Some 80 percent of the New York City subway system was up and running. Not everything went perfectly — there were delays and crowds and, for those living on defunct lines, long walks or bus rides to open stations — but it was a far cry from the prolonged collapse many feared after the wrath of Sandy.

The challenges, as detailed by MTA chairman Joe Lhota the morning after the storm, were daunting. Seven tunnels under the East River were flooded. An unknown amount of equipment had been exposed to corrosive salt water. Yet the system recovered in time for Monday’s morning commute, which even the MTA’s usual critics acknowledged was nothing short of a miracle. How did they do it?

The first thing the MTA did right was informed by a colossal mistake. After the 2010 blizzard, which embarrassed the mayor and took out the subway for days, the MTA was too slow bringing its trains and equipment somewhere safe and dry. “We kind of dropped the ball and we learned from that,” said Tom Prendergast, president of New York City Transit, the part of the MTA that handles city subways and buses. This time the MTA shut everything down on Sunday evening, the day before the storm arrived. Waiting longer would have wasted time and man power needed for the cleanup afterwards.

Even so, Prendergast says, the system wasn’t prepared for what came next. While Irene had brought the water within a foot or two of flooding the subway entrances and ventilation gratings, Sandy’s fourteen-foot surges brought the water gushing in. Half of the subway system’s fourteen under-river tubes flooded. A few filled up end to end, much like the MTA’s Brooklyn-Battery Tunnel. They couldn’t even send workers out to assess them until after the second surge at the next high tide Tuesday morning.

Pumping began soon after — or “dewatering,” as the pumping industry calls it. Other city agencies had to rely on outside contractors to pump their tunnels. But it happens that the subway system already had its own toys. Each of the system’s under-river tunnels has a sump to deal with everyday seepage, and each also has a tube fixed to the side called a discharge line. Starting Tuesday, the system sent in its “pump trains” — diesel powered trains with five or six cars, run by just five or six workers. Underneath the trains are pumps, moving hundreds of gallons of water back into the river every minute. “You take the pump train and you bury the first car up to the floor level so it’s underwater,” Prendergast says, “and you hook it up to the discharge line and you start pumping the tunnel dry.”

The only problem was the MTA had seven flooded tunnels and just three pump trains. It can take up to 100 hours to pump the largest tubes, fully loaded with water, or as little as five or six hours for those that are smaller or less fully flooded. It was time to prioritize. “If you let the size of the effort overcome you, you can’t get started,” Prendergast says. “So you just take on the most important tunnels first. It’s like the old story: How do you eat an elephant? One bite at a time.” The highest priority was the 4, 5, and 6 Lexington line — the highest capacity line in the United States in terms of customers carried — which connects to the Joraleman Street tunnel. Then there was Clark Street tunnel, which connects to the West Side IRT 2 and 3 trains. Those lines were luckily not completely flooded. The Army Corps of Engineers helped out with some crucial work on the Montague Street tunnel, but Prendergast says the MTA handled the majority of the effort.

At the same time tunnels were being pumped, there were some 600 miles of other track to examine for damage, at least twenty miles of which is exposed to the elements, like the elevated Dyer Avenue line, the Sea Beach line, and the Brighton line in Brooklyn. “We had a lot of downed trees and debris that had to be cleared, so that effort started,” Prendergast says. The system’s 2,700 track workers worked double shifts, then they were fed and given lodging so they could do another double the next day. These same workers also cleaned garbage and debris and silt out of the freshly pumped tunnels.

Next came the moment of truth: Assessing the damage of salt water on the equipment in the tunnels. “You can see right away if the tracks are okay,” Prendergast says. “But everything else — power to move trains and energize communications and signals equipment — they can do some tests, but the ultimate test is powering it up.” They found that different tunnels were affected in different ways, depending on the mix of salt water from the ocean and fresh water from the Hudson. “If it’s more fresh water, all you have to do is dry out the equipment — you don’t necessarily have to clean it. But if you have salt water, it dries and leaves a salt residue. Salt is conductive. So you want to clean that salt off. Otherwise you can have a short circuit and you could burn the equipment.”

In this effort, the MTA found they had been given a little grace period, courtesy of the massive power failure in Manhattan south of 39th Street. Instead of the city waiting for the equipment to be cleaned and tested, it was the subway system waiting for the electricity to run final tests. On Thursday, Lhota announced that some service was being restored — the 7 between 74th Street and Main in Queens, and the M between 34th Street in Manhattan and Jamaica in Queens. He also said tunnels for the 4, 5, and F were just waiting for Con Ed to turn on the power. “We were trying to communicate we were willing to get back to normal as soon as possible,” Prendergast says.

By then, the “bus bridge” between Brooklyn and Manhattan had proven woefully inadequate, with long lines stretching around the Barclays Center and tremendous traffic making most commutes practically pointless. “If the bus bridge did anything,” Prendergast says, “it helped underscore for people how our rail system has a lot more utility than our bus system.”

The first lines connecting Brooklyn to Manhattan opened on Saturday, after Con Ed turned on the lights. On Monday, it was back to business, more or less. Of course, major challenges remain: Many stations will remain closed for a long time, like the South Ferry on the 1 line and 207th Street on the A line because of water. The A, L, B, and G lines, among others, are still partially or entirely closed. The tracks across Jamaica Bay to the Rockaways are devastated and could take weeks or months to repair.

In the future, Prendergast says, the system will have to rethink the way it designs its infrastructure. At the very least, ventilation ducts and gratings should be moved higher up or built so that they can be covered and made water-tight along with station entrances. But today, at least, there was a chance for the MTA to exhale a little. “New Yorkers are very resilient; we could not have gotten through it this far without their support,” says Prendergast. “When I look back, given all that we were able to take care of and get service restored, it was pretty amazing to do all we could do.”