Image copyright Reuters Image caption Andrew Scheer celebrates after winning the leadership

Canada's Conservatives have chosen a youthful new leader to take them into the next federal election.

Former House of Commons speaker Andrew Scheer, 38, beat 12 other contestants in a razor-thin victory.

He emerged as the winner on the thirteenth ballot in the leadership contest, narrowly defeating his primary rival, former foreign affairs minister Maxime Bernier, with 51% of the vote.

Mr Scheer will lead the party against Justin Trudeau's Liberals in 2019.

Speaking on Saturday to party faithful gathered in Toronto, Mr Scheer offered a message of unity to the party built some 14 years ago on a coalition of progressive, populist and social conservatives.

"We all know what it looks like when Conservatives are divided," he said. "We will not let that happen again. We win when we are united."

More than 141,000 Conservative party members cast a ballot in the contest.

Unlike in federal elections in Canada where the winner takes all, the Conservative leadership race used preferential ranked ballots, which means that Mr Scheer was not everyone's first choice.

Still, Mr Scheer was seen as a consensus candidate who received strong support from the party caucus.

Few of the contestants in the crowded race were household names, except for businessman and reality TV star Kevin O'Leary, who unexpectedly dropped out of the contest in April.

Mr O'Leary threw his support behind Mr Bernier but that backing failed to get the Quebec politician, who ran on a free-market, libertarian slate, across the finish line. He ended the night with 49% of the vote.

Former Conservative prime minister Stephen Harper resigned in 2015 after he was defeated in the federal election by Mr Trudeau's Liberals.

Mr Harper held together the right-of-centre federal party for a decade, winning three consecutive elections between 2006 and 2011.

He was replaced on an interim basis by Rona Ambrose, a veteran federal politician who recently announced her retirement from federal politics.