Canada's Liberal leader Justin Trudeau, son of a popular former prime minister, has won the general election in a landslide that ended nine years of Stephen Harper's Tory rule.
In a concession speech, as his party announced his plans to step down as Tory leader, Harper said that "the outcome is not the one we hoped for".
But, he added, "We gave everything we had to give and we have no regrets".
For many Canadians the vote was a referendum on Harper's management style, criticised as autocratic, and on who was better placed to put a struggling economy back on track.
Trudeau campaigned on a pledge to raise taxes on the richest Canadians and lower them for the middle class.
The 43-year-old Trudeau – who ran a combative campaign and offered up what he called a "new vision" for the nation – would form a majority government with more than 180 of the 338 seats in the House of Commons, according to Elections Canada on Monday (local time).
Public opinion had swung wildly during the hard-fought campaign, one of the longest in the country's history. But final polling showed Trudeau's Liberals eight points ahead of Harper's Tories - an edge apparently borne out at the ballot box.
Early results showed the Liberals swept all 32 seats in Canada's Atlantic provinces, doubling their popular support in the region, scored well in key Ontario and Quebec battlegrounds, and made gains throughout the western provinces.
The party came from behind late in the campaign, with Trudeau – the eldest son of Pierre Trudeau, considered the father of modern Canada – promising "not just a change in government, but a better government".
"Tonight Canada is becoming the country it was before," Trudeau said in his victory address.
"Canadians from across this great country sent a clear message tonight - it's time for a change in this country, a real change," he said.
Trudeau was elected Liberal leader only two years ago, coming after two past leaders failed to unseat Harper in 2008 and 2011 and subsequently resigned.
He appears to have made good on his hope to recreate the "Trudeaumania" that swept his charismatic father to into office in 1968.
Harper, who took power in 2006, had been seeking a fourth term in office.
But Trudeau tapped into a strong desire for change in administration, and took advantage of an all-time low in Harper's popularity.
Indeed, "there was a kind of mini Trudeaumania" surrounding the campaign, said Claude Denis, a politics professor at the University of Ottawa.
The 11-week campaign was one of the longest in Canada's history, and gave voters unprecedented exposure to party leaders and their ideas in five debates and almost daily stump speeches.
Besides campaigning on a pledge to raise taxes on the richest and lower rates for middle-income Canadians, Trudeau said he would spend billions on infrastructure to give the struggling economy a boost.
He also pledged to legalise marijuana.
Along the way was debate on how Canada should handle a record influx of people fleeing the war in Syria, a court ruling quashing a ban on the niqab and economic recession.
The left-leaning New Democratic Party, led by Thomas Mulcair, had hoped to build on its second-place finish in the last ballot, in 2011, and govern for the first time.
But the party stumbled in recent weeks. It lost key support in Quebec province over its opposition to the popular ban on the niqab, the head covering worn by some Muslim women. It looked to finish in third place.