It’s “The Donald” to the rescue.

Mega-developer and TV personality Donald Trump has agreed to buy Ed McMahon’s Beverly Hills house for an undisclosed amount and allow McMahon to continue living in it. Details of the deal are still being ironed out, but Trump’s interest is regarded as an act of benevolence.

“I don’t know the man, but I grew up watching him on TV,” Trump said in an exclusive interview with The Times.

McMahon, 85, was facing foreclosure within two weeks on his Beverly Hills home of 18 years. The aging television icon, who was Johnny Carson’s sidekick for three decades, defaulted on $4.8 million in mortgage loans with Countrywide Financial Corp. He said in interviews that he was unable to work because of a neck injury that occurred about 18 months ago.

Trump said he stepped in because helping McMahon “would be an honor.” His plan is to buy the home from the lender and lease it back to McMahon.

“When I was at the Wharton School of Business,” Trump said, “I’d watch him every night. How could this happen?”

The deal with Trump was cemented this past weekend when McMahon’s listing agent, Alex Davis of Hilton & Hyland in Beverly Hills, flew to New York to make a personal appeal to Trump. Davis declined comment.

The six-bedroom, five-bathroom house had been on the market for about two years. At one point, it was listed at more than $7 million but dropped in increments, winding up this weekend at $4.6 million. McMahon purchased the house in 1990 for $2.6 million, according to public records.

Lenders set a deadline of two weeks for another buyer to be found.

ann.brenoff@latimes.com