Kevin O'Leary is dropping out of the Conservative leadership race and endorsing Maxime Bernier.

The businessman and reality TV star is ending his campaign only hours before the last leadership debate in Toronto, and two days before party members can start casting their votes. O'Leary's name will remain on the ballots as they've already been printed and mailed, the party said.

O'Leary said Wednesday he was confident he could win the Conservative race, but raised doubts he could defeat Prime Minister Justin Trudeau in the next election. He cited his failure to gain traction in Quebec and his poor French-language skills as reasons for dropping out of the leadership race.

"The Liberals politically own Quebec. Without growing the Conservative base in Quebec, beating Trudeau in 2019 would be a huge challenge," O'Leary said at press conference with reporters in Toronto.

"It would seem foolish, even selfish, to win the leadership knowing I don't have the path, a high probability [of winning the next federal election]. The likelihood of me gaining a lot of seats in Quebec was low. I was weak in Quebec, it's a fact, people know this."

O'Leary said Bernier was best placed to pick up seats for the party in the province. "Look at how many times Quebec has determined the federal outcomes. It is the Florida of Canada, it often decides for the country."

"Trudeau has to go, and this is the man to replace him," he said of Bernier. "We need to take back this country from a very weak manager who's destroying the economy."

'Worked like hell'

O'Leary told reporters he has "worked like hell on this campaign," calling it the "hardest job I've ever had."

"This was not an easy decision for me to make but after much thought and deliberation, it is the right one for the Conservative Party and the country," he said. "I want the DNA of my policies and objectives to survive into the general election. The candidate that best mirrors my policies is Maxime Bernier."

O'Leary leaves the Conservative race and speaks to reporters 1:31

O'Leary has spent the better part of his relatively short campaign — he entered the race in January — taking jabs at Trudeau, branding the prime minister "surfer dude" and calling his leadership a "disaster" for the country. He has also said Trudeau negotiating with U.S. President Donald Trump is like "Bambi versus Godzilla."

O'Leary has not left his Conservative opponents unscathed, and, despite his endorsement of Bernier, the two candidates have sparred over allegations of membership fraud and vote buying. The Quebec MP called O'Leary a "loser" after he went public with concerns about vote rigging.

"He's a bad candidate. Instead of trying to win people over by putting out a platform, he's throwing mud to try to save his campaign," Bernier said of O'Leary in a March 17 email to supporters. "Kevin O'Leary is a loser. I'm a winner."

When asked about the harsh tone, Bernier said the two had a "nice competition but now we are together."

"He was critical during a campaign? Welcome to politics. We're in a civil war here," O'Leary said, and the party would come together after it was over "like mercury."

Kevin O'Leary is dropping out of the Conservative leadership race and is endorsing his opponent Quebec MP Maxime Bernier. His name remains on the leadership ballot, however. (Nathan Denette/Canadian Press)

The two men first met at O'Leary's cottage in Muskoka, Ont., last summer when Bernier asked the businessman to endorse his campaign for leader. Despite the later war of words, sources close to the Bernier campaign told CBC News that the two men got along well in that first encounter and they built a "good rapport."

The former Dragons' Den star, who now appears on the American show Shark Tank, has attracted considerable media attention, and polls had pegged him to be the candidate with the most votes on the first ballot.

Bernier has been a close second in those same polls, and O'Leary's endorsement could give him a significant advantage over the 12 other candidates still in the race.

The Boston-based pitchman has signed up some 35,000 members, largely based on his personal appeal and his promise to kill the national carbon tax, cut red tape and "unbridle" Canada's natural resources.

O'Leary has been accused of not taking the leadership race seriously. During the campaign, he has spent many days in the U.S., selling his wares on QVC and offering commentary on U.S. cable networks.

Kevin O'Leary was featured on an hour-long segment on American home shopping channel QVC to sell his wine during the Conservative leadership campaign. (Screenshot from QVC/CBC)

The decision came only three hours after his campaign team sent a fundraising email — signed by O'Leary himself — to supporters.

"The last leadership debate is tonight, and it's your last chance to join our big fundraising push before I go on stage," the email said. "My team will be showing me a list with the names of those who donated. I need your name to be on that list. I want to know you're in my corner. I'm fired up, and I know you are too."

O'Leary raised more than $1 million in the first three months of 2017.

The federal Conservatives will elect their new leader on May 27.