Warren Buffett's deal to back Home Capital Group Inc. does more than support a struggling mortgage lender -- it's a vote of confidence for a housing market that everyone from investors to global ratings companies say is a bubble ready to burst.

Buffett's Berkshire Hathaway Inc. is buying a 38 percent stake in Home Capital for about C$400 million ($300 million) and providing a C$2 billion credit line to backstop the Toronto-based lender. With the deal, the billionaire investor is wading into a housing market that's been labeled overvalued and over-leveraged, with home prices in Toronto and Vancouver soaring as household debt hits record levels.

Naysayers "have been dissing our banks and dissing our real estate market for years because we didn't go into the can the way that the Americans did in 2008 to '09, and they've been waiting for a collapse in our markets," said Ross Healy, chairman of Toronto-based Strategic Analysis Corp. and a Home Capital investor who bought shares when they dipped to C$6 last month. "Am I concerned about that? Nope. So thank you, Warren Buffett."

Home Capital became a poster child for the ills in Canada's housing market after it was accused by regulators in April of misleading investors about mortgage fraud. That sparked a run on deposits and raised concerns it would be the catalyst to bring down the housing market that organizations including Fitch Ratings Inc. and the International Monetary Fund warned was already at risk of correction.

Buffett's equity investment and credit line for Home Capital suggest he's not betting on a collapse anytime soon. At the same time, he's being rewarded for the risk, buying shares at a 33 percent discount and making 9 percent interest on any tapped portion of the loan.

"Home Capital's strong assets, its ability to originate and underwrite well-performing mortgages, and its leading position in a growing market sector make this a very attractive investment," Buffett said in a Home Capital statement late Wednesday night.

Buffett joins a long list of investors who have taken a look Home Capital's assets, even amid the housing-market risk and run on deposits. The company drew interest from Onex Corp., Brookfield Asset Management Inc., Catalyst Capital Group Inc. and others, according to people familiar with the matter. Home Capital was also in discussions with Canada's major banks about refinancing its existing line of credit with a Canadian pension fund. Home Capital this week sold a C$1.2 billion portfolio of commercial mortgages to KingSett Capital Inc., a Toronto-based private equity firm.

Warren Buffett has become the lender of last resort for Home Capital https://t.co/xZby7z6BcTpic.twitter.com/JNQRR2h973 — Bloomberg (@business) June 22, 2017

Buffett's investment could only be positive in a country where risks of housing are overblown, said Alan Hibben, one of the new board members put in place in May to rescue the company. In Toronto, average home prices have rallied 130 percent in the past decade to C$863,910 last month. In Vancouver, they're up 115 percent to C$1.1 million in the same period. Though home price gains have slowed over the past six weeks, there is little risk of a crash, Hibben said.

Home Capital is "a very attractive business here in a marketplace that has already been cooled to some extent by government policy and may be cooling a bit more," Hibben, a former RBC Capital Markets banker, said on Bloomberg Television. "While obviously we're very interested and looking very closely at home values -- particularly in Toronto and greater Vancouver area -- we're not seeing this to be as dire as some commentators might see it, particularly those outside of Canada."

Fitch seemed to mirror that view, saying that although unsustainable home prices and historically high debt make Toronto and Vancouver vulnerable to a correction, the housing system would likely not follow the housing-sparked downturn in the U.S. in 2008.

"Canadian banks are subject to rigorous oversight and regulations requiring prudent mortgage lending and underwriting standards. What's more, credit quality for Canadian mortgage loans remains strong," Fitch analysts led by Kate Lin said in a report Thursday. Non-prime originations in Canada account for about 10 percent of volume, compared with a pre-crisis peak of 50 percent in the U.S., according to the report.

Home Capital mortgages account for about 1 percent of the country's home loans, but it's one of the biggest lenders to new immigrants -- about 250,000 of whom move to Canada each year -- as well as the self-employed, first-time buyers and those with poor credit histories. It's become a more important player in the past few years as federal mortgage regulations made it harder for these borrowers to work with banks, which now require better credit scores and charge higher rates.

Despite dealing with riskier borrowers, Home Capital has fewer loans in arrears than traditional lenders do. Non-performing loans comprised only 0.24 percent of Home Capital's gross book, according to the company's first-quarter results. Canadian lenders had an average arrears rate of 0.28 percent as of February, according to the Canadian Bankers Association.

Consumers holding C$1.4 trillion in total mortgage debt nationwide aren't defaulting on their home loans even with the record levels of debt. They've been helped by low mortgage rates -- as low as 2 percent -- and an economy that's growing at the fastest pace among Group of Seven countries.

Despite the boost from Buffett's investment, the troubles aren't over yet for Home Capital. The company still needs to find a replacement chief executive officer after Martin Reid was forced to leave the firm, and founder and former CEO Gerald Soloway retired from the role last year. Board directors said on a conference call Thursday that the search was progressing well and a new CEO would be announced in July.

The terms of the credit facility Buffett gave are also not that much better than a C$2 billion loan Home Capital had from Healthcare of Ontario Pension Plan, said James Price, director of capital markets products at Richardson GMP Ltd. Home Capital will pay 9 percent on any drawn capital and 1 percent on the standby amount. Hibben said the company expects to tap the new line soon to pay off part of the HOOPP loan.

"Home Capital certainly can't run their business with a 9 percent cost of capital," Price said by phone from Toronto. "Frankly, outside of the Buffett halo, the terms don't look that good for existing shareholders. They get significantly diluted and they get diluted at a much lower price than they're trading at."

The company also needs to win back depositors to inject funds into the savings accounts that back its mortgages, said Stephen Boland, an analyst at GMP Securities LP. Home Capital's high-interest deposit levels have stabilized at about C$110 million, down from C$1.4 billion in early April. The level of guaranteed investment certificates have fallen to about C$12 billion.

"You need a stamp of approval from somebody that will hopefully bring back the agent, the broker that buys a GIC for their client," Boland said. "Warren Buffett is certainly the biggest name. The question is: will it bring them back?"

Bloomberg's Kristine Owram, Allison McNeely and Erik Hertzberg contributed.