Conservative MP Andrew Scheer has scored a major upset in the federal leadership race, beating out front-runner Maxime Bernier to take the helm of the party.

Mr. Scheer won on the 13th ballot with 51 per cent of the available points to Mr. Bernier's 49 per cent. Mr. Bernier, a Quebec MP, had led all 12 ballots to that point, but Mr. Scheer benefited from a final push when Erin O'Toole's support was redistributed to the last two contenders. The final results were unveiled at 8:13 p.m. at the Congress Centre in Toronto, about two hours after the first-round results came out. More than 140,000 votes were cast.

Related: Who Scheer is and what happens next

Story continues below advertisement

From the archives: Why Andrew Scheer could be the next Conservative leader

Analysis: Conservative elect Stephen Harper 2.0

Mr. Scheer, the 38-year-old former Commons Speaker and father of five, received a major boost from social Conservatives, whom he said would have the freedom to speak their minds in his party. He has said his government wouldn't propose legislation on subjects such as abortion, even though he is against it.

The Saskatchewan MP focused mostly on projecting a positive tone in the race, lending some to call him Stephen Harper with a smile. He has repeatedly said the party lost the past election not because of its policies but because of the way it communicated them to the broader public.

Mr. Bernier's team said the Scheer victory was due to the social-Conservative vote and the strong showing of candidate Brad Trost, who expressed his discomfort during the race with "the whole gay thing" and said he would vote for pro-life bills.

Mr. Scheer's campaign manager, Hamish Marshall, said Mr. Scheer received a big bump from Mr. Trost, who fell off the ballot with 14.3 per cent of the vote, as well as Lisa Raitt. Mr. Marshall also said Mr. Scheer benefited from second-place support from Mr. O'Toole, the third-place candidate who dropped off the ballot with 21-per-cent support.

Mr. Scheer's campaign focused on sweeping pledges such as ending corporate welfare and balancing the budget in two years, but mostly incremental policies such as more support for parents of home-schooled children, withholding federal grants for universities that curb free speech, and scrapping the GST and HST from home heating and electricity.

Story continues below advertisement

Conservative members were asked to rank up to 10 of the 14 official candidates on their ballot. The votes are counted by riding, with each of the country's 338 ridings given the value of 100 points in the final tabulation.

While Kevin O'Leary was still officially in the race, he quit the contest last month to endorse Mr. Bernier.

Mr. Scheer, unlike Mr. Bernier, supported supply management, the system that regulates prices on dairy and poultry in Canada. Mr. Bernier's position hurt him in Quebec and was a key part in Mr. Scheer's success.

Mr. Scheer also had the support of four Quebec MPs. In the final ballot, Mr. Scheer beat Mr. Bernier in the Quebecker's own riding of Beauce, where there are many farmers, 51.11 per cent to 48.89 per cent.

In his victory speech, Mr. Scheer focused on unity, telling Conservatives old and new that "You are all welcome and this party belongs to all of you."

"We all know what it looks like when Conservatives are divided," he said.

Story continues below advertisement

"We will not let that happen again."

He said the leadership candidates helped to grow the party to its biggest membership in history and vowed to beat Justin Trudeau in the next election.

"There is hope because Conservatives are united. We are positive, we have strong Conservative values, and we will work together … to win in 2019."

Mr. Scheer said the next Conservative government will cut taxes and make it easier for the private sector to create meaningful jobs.

He thanked his family and campaign team, as well as interim leader Rona Ambrose and Mr. Harper.

He said he also believes the party can do better in Quebec in the next election.

Story continues below advertisement

Mr. Scheer said that as prime minister, he will focus on Conservative policies that create prosperity and opportunities for Canadians.

"I will bring us back to balanced budgets and end corporate welfare," Mr. Scheer said.

He called the Liberal carbon tax a "cash grab," and said he would defend any province that does not impose one.

Candidates who were eliminated also included Deepak Obhrai, Andrew Saxton, Rick Peterson, Chris Alexander, Steven Blaney, Kellie Leitch, Pierre Lemieux and Michael Chong.

Mr. Trost agreed that after his elimination on the 11th ballot, his supporters gave a major push to Mr. Scheer and helped to propel him to victory. Asked what message this sent to Mr. Scheer and the party, Mr. Trost told The Globe and Mail: "You need to listen to my voters."

The Campaign Life Coaltion said the results showcased the political strength of "pro-life and pro-family voters."

Story continues below advertisement

"In addition to congratulating Scheer on his victory, we congratulate and thank Brad Trost and Pierre Lemieux who were unapologetic in their pro-life convictions, and made pro-life issues part of their leadership platforms," Jim Hughes, National President of Campaign Life Coalition, said in a statement.

At a news conference after his victory, Mr. Scheer said he does not feel beholden to social-conservatives or anyone else who contributed to his victory. He said he believes in the right of MPs to speak about all issues ‎that are dear to them, including abortion.

Still, he said as leader, he will encourage his caucus members to table bills that unite rather than divide the party.

"Every kind of conservative needs to have a home in our party and feel welcomed. Every kind of conservative played an important role in this leadership race," Mr. Scheer said. "‎We had libertarian conservatives... we had social conservatives, yes, but we also had fiscal conservatives, foreign-policy conservatives, democratic-reform conservatives."

Mr. Bernier took the defeat graciously, although he was clearly pained to have led all the way except on the last ballot.

"That was not what I was expecting, as you may know, but the members decided and that's democracy," he told reporters gathered around him. "I will sleep soundly tonight. I defended the ideas that I believed in and I see that many people in the party believe in these ideas of liberty and responsibility."

Story continues below advertisement

Mr. Bernier pledged his full collaboration to Mr. Scheer.

In a brief interview, Mr. O'Toole also offered his full support to the new leader.

"We have a strong party, I'm very proud and I'll work with Andrew," he said.

"I congratulate Andrew for his success," said Prime Minister Justin Trudeau from Italy. "I congratulate everyone who was part of what was a strong democratic process .... I look forward to working with everyone who sits in the House."

Mr. Trudeau then called Mr. Scheer to congratulate him.

They discussed "making Parliament work for Canadians and the important relationship with the United States," according to a statement from the Prime Minister's Office.

They have agreed to meet in person in the coming weeks.

With files from Robert Fife.