COVID-19 damaged Hauppauge church pastor Doug Jansson’s lungs so severely, death was just hours away.

Doctors summoned his wife, Kelly, to Stony Brook University Hospital. It was Dec. 23, 2020, and Kelly Jansson was hoping she could be there to comfort her husband of two decades in what were possibly his dying moments. Because of a November change in visitor policy for families of patients facing “imminent end-of-life situations,” she could.

“They let me come in as a compassionate visit to say goodbye,” she told Newsday Wednesday night, her voice cracking from emotion.

“I went over there to pray over him,” she said, “and never told him why.”

She’ll never need to now.

Not long after Doug Jansson had been so close to death, unbelievably, he started to rally with help from a device that acts like artificial lungs. The device earned FDA approval in 2020 for patients with severe reactions to the virus.

After 53 days, Jansson, of Smithtown, and lead pastor at Living Word Church in Hauppauge, left Stony Brook University Hospital Wednesday afternoon.

He said it was the first time he had seen his three children, ages 12 through 16, since an ambulance rushed him to the hospital Dec. 12.

“God was very merciful to me and I’m very grateful,” Jansson, 42, said Wednesday night. How did it feel when he wrapped his arms around his wife and children?

“Like a dream,” Jansson said. “I couldn’t hold them tight enough. I couldn’t hold them near enough. You have the aching in you to see them.”

As he left the hospital, Jansson was hailed with loud cheers and applause by a hospital staff well-schooled in that now-familiar tradition. Jansson then checked into St. Charles Hospital in Port Jefferson for physical and respiratory therapy.

Because of the virus’ unrelenting toll on the lungs, it’s been a frustrating slog to get moving again.

“I can only walk a few steps with a walker right now,” Jansson said. “I need my oxygen levels to be strengthened a bit and my muscles.”

But even so, based on an accounting of his time at Stony Brook provided by hospital staff, mostly breathing on his own with some help from oxygen signaled his lungs had gotten the best of the virus.

Hospital staff connected Jansson to a ventilator on Dec. 24. But that didn’t work. Next, they put him on something called a extracorporeal membrane oxygenation machine, more commonly known as an ECMO, which provides cardiac and respiratory support to patients whose hearts and lungs aren’t funtioning properly.

The machine also is used for life-threatening conditions such as shock from a heart attack or a severe lung infection.

Jansson was placed on it for five days, said Dr. Allison J. McLarty, ECMO program director at Stony Brook University’s Heart Institute.

The situation was dire, she said.

“He had really bad lung disease,” McLarty said. “If we had not put him on ECMO that night, he may not have survived. He was very close to dying.”

Kelly Jansson, director of women’s ministries at the Hauppauge church, said that after her husband was taken off the ECMO, he remained on a ventilator for another week. After weeks of worry and tears of sadness, Wednesday meant relief and tears of joy.

“My husband is a miracle,” she said. “God spared his life and answered our prayer. And not just our prayers, but other prayers because he is loved by so many.”

Before Doug Jansson’s hospitalization, the family’s church organized food drives to help those affected by COVID-19. The church held “prayer parades,” often caravaning slowly past Long Island hospitals, members holding up signs of support for the overworked staffs.

That staff showed a similar commitment to her spouse and family, Kelly Jansson said. “These doctors and nurses and other staff, they truly care about the person. They are not just there for a paycheck. They’re selfless.”

In that capacity, Dr. Robert Nocito, a medical resident in emergency medicine, treated Doug Jansson after he was taken off the ECMO, but remained on a ventilator. Nocito’s job was to quickly help his patient get off a breathing machine so familiar to so many after the past year.

Nocito said that when he learned Jansson was a big New York Jets fan, he set up a Facetime call with his friend, retired Jet defensive back Erik Coleman.

“It made him smile,” Nocito said. “I hope it helped Doug. … Our job as doctors is to make people feel better and heal the sick. It doesn’t always involve medicine.”

Jansson said the moment did pick him up. So did his many talks with medical staff, and the countless phone calls with his family, which, the pastor is convinced, kept him alive.

“It was amazing to talk to doctors and nurses,” he said. “I would ask them how they’re doing. It was really powerful to be able to encourage them and help some of them through the discouragement and the PTSD a lot of them have, because of all they’ve gone through losing so many patients.”

Jansson said he’s looking forward to getting out of physical therapy in a week or two and grabbing a slice of cheese pie at his favorite pizza joint. He said he also can’t wait to go on a date with his wife and play sports with his children.

As for the near-death experience, and what he gleaned from it, the message he will share with his parishioners is simple:

“Be close to Jesus each day,” Jansson said, “and impact as many people as we can for him.”