Liberal party leader Justin Trudeau has been elected as Canada's prime minister after taking his party to a stunning victory and ending the nine-year government of Conservative leader Stephen Harper. Preliminary results showed the Liberals were poised to win by a comfortable margin.

Trudeau, son of former Prime Minister Pierre Trudeau who governed Canada for 16 years, was a late entrant into the 11-week-long election campaign with ambitious commitments and promises of a sea of change. Trudeau's promises of running a C$10bn (£4.96bn) budget deficit for three years, legalising marijuana, massive infrastructure investment, and middle-class tax cuts became new symbols of hope in the election campaign, which was one of the longest in Canada's history.

The photogenic 43-year-old leader has catapulted the Liberals into first place, from a distant third in the last parliamentary elections. The Canadian House of Commons contains 338 seats, in which 170 seats are needed to form a majority government. While the poll is yet to be finalised, the Liberals were leading or winning in 187 districts and the Conservatives managed to lead in 104.

The Conservatives, who questioned Trudeau's abilities to lead the country throughout the campaign, have conceded defeat. "The people are never wrong," said Harper as the results emerged. The incumbent is also expected to step down as Conservative leader though he has not explicitly mentioned his resignation in his address.

"Friends our country is one of the most enduring democracies in the world today, and today, for the 42nd time in 148 years ... while tonight's result is certainly not the one we had hoped for, the people are never wrong. The disappointment you also feel is my responsibility and mine alone," said Harper.

The Tories are expected to form the opposition, pushing the New Democratic Party (NDP) led by Tom Mulcair into third position. The election results were also a crushing blow for the NDP as it was considered a frontrunner at the start of the election campaign. Mulcair, who failed to capitalise on the anti-Harper wave, also admitted defeat after the results but did not say anything about his political future.

Despite the poor performance of the NDP, Mulcair sounded optimistic in his post-election address, saying: "Canadians have asked the NDP to continue bearing hope and optimism that characterise our party. We ran in this election with the most women and the most indigenous candidates, not just in the history of our party, but in the history of Canada. This is something that makes me immensely proud."