Dominic Raab has said he was “really worried” the PM could have died from Covid-19 after he was admitted to intensive care in the spring.
The foreign secretary stood in for Boris Johnson during his time in intensive care and while he recovered.
Speaking to the Conservative Party conference, Mr Raab said the virus “nearly took the life” of the PM.
Mr Raab also said he worried for the PM’s fiancee Carrie Symonds but “always had faith” he would “pull through”.
Mr Johnson spent three nights in intensive care at London’s St Thomas’ Hospital in April after contracting coronavirus.
Speaking about his experience after leaving hospital, the PM said it “could have gone either way” and thanked healthcare workers for saving his life.
Mr Raab told the virtual conference that coronavirus had “hit us hard, taking lives on a tragic scale”.
“It nearly took the life of our prime minister, our friend as well as our leader.
“I get asked a lot how I felt, when I covered for him.
“Well, I really worried we might lose him, and I was worried for Carrie (Symonds), pregnant with baby Wilf.
“But I always had faith that with the outstanding NHS care he received and his fighting spirit, he’d pull through.”
Admitting there would be “lessons to be learnt” following the government’s handling of the crisis, the foreign secretary added: “I have to say, for every hurdle we faced, with every heart-rending loss, there was also a tale of courage, a moment of inspiration.”
Mr Raab also spoke about the prospect of a post-Brexit trade deal between the UK and the EU.
But Mr Raab said that although the government wanted a free trade deal with the EU, “any deal must be fair”.
“The days of being held over a barrel by Brussels… are long gone,” the foreign secretary said.
He added there was “no question the government will control our fisheries”.
Both sides have been calling on the other to compromise on key issues, which include fishing and government subsidies.
Also speaking at the conference, Michael Gove outlined the government’s plans to move more Civil Service jobs outside of London – part of its “levelling up” agenda to spread investment and opportunity beyond London and south-east England.
The Cabinet Office minister said “far too many government jobs” were based in Westminster and Whitehall.
Mr Gove added: “We have an amazing Civil Service and it has drawn its resources and people from lots of different communities – I think we now need to give back to those communities as well.”
Plans to open a second headquarters in Leeds were also announced.
The new headquarters will provide the party with “a base at the heart of the blue wall”, party co-chairman Amanda Milling said, referring to the northern constituencies who voted for the party for the first time at the general election in December.