TORONTO: Canadians voted for a sharp change in their government Monday, resoundingly ending Conservative Stephen Harper's attempt to shift the nation to the right and returning a legendary name for liberals, Trudeau, to the prime minister's office.

Justin Trudeau, the son of late Prime Minister Pierre Trudeau, became Canada's new prime minister after his Liberal Party won a majority of Parliament's 338 seats. Trudeau's Liberals had been favored to win the most seats, but few expected the final margin of victory.

Harper, one of the longest-serving Western leaders, stepped down as the head of Conservatives, the party said in a statement issued as the scope of the loss became apparent.

Trudeau, tall and trim at 43, channels the star power — if not quite the political heft — of his father, who swept to power in 1968 on a wave of support dubbed “Trudeaumania.”

Pierre Trudeau, who was prime minister until 1984 with a short interruption, remains one of the few Canadian politicians known in America, his charisma often drawing comparisons to John F. Kennedy. A bachelor when he became prime minister, he dated actresses Barbra Streisand and Kim Cattrall.

Supporters of Liberal Party leader Justin Trudeau cheer at his election night headquarters during Canada's federal election in Montreal, Quebec, October 19, 2015. —Reuters

Justin Trudeau, a former school teacher and member of Parliament since 2008, becomes the second youngest prime minister in Canadian history.

Trudeau, who has re-energised the Liberal Party since its devastating electoral losses four years ago, promises to raise taxes on the rich and run deficits for three years to boost government spending.

His late father, who took office in 1968 and led Canada for most of the next 16 years, is a storied name in Canadian history, responsible for the country's version of the bill of rights.

“We have a chance to bring real change to Canada and bring an end to the Harper decade,” Trudeau said in Harper's adopted home province of Alberta, traditionally a Conservative stronghold.

Canada has shifted to the center-right under Harper, who has lowered sales and corporate taxes, avoided climate change legislation and clashed with the Obama administration over the Keystone XL pipeline.

A Liberal Party supporter watches a screen showing results for Justin Trudeau during Canada's federal election in Montreal, Quebec, October 19, 2015. —Reuters

The Trudeau victory will ease tensions with the US. Although Trudeau supports the Keystone pipeline, he argues relations should not hinge on the project. Harper has clashed with the Obama administration over other issues, including the recently reached Iran nuclear deal.

Trudeau's opponents pilloried him as too inexperienced, but Trudeau embraced his boyish image on Election Day. Sporting jeans and a varsity letter jacket, he posed for a photo standing on the thighs of two his colleagues to make a cheerleading pyramid, his campaign plane in the backdrop with “Trudeau 2015” painted in large red letters.

“A sea of change here. We are used to high tides in Atlantic Canada. This is not what we hoped for,” said Peter MacKay, a former senior Conservative cabinet minister, shortly after polls closed in Atlantic Canada.

The Liberals were elected or were leading in 185 districts, with Trudeau winning his Montreal district. The party needed 170 to gain a majority.

The Conservatives were next with 97, followed by the New Democrats at 28 and Bloc Quebecois with nine.

Harper, 56, visited districts he won in the 2011 election in an attempt to hang onto them. On Saturday, he posed with Toronto's former crack-smoking mayor, Rob Ford, in a conservative suburb.

Harper had said he would step down if his party didn't win the most seats. Former colleagues of Harper said he would be personally devastated to lose to a Trudeau, the liberal legacy he entered politics to destroy.

Harper's long-term goal was to kill the widely entrenched notion that the Liberals — the party of Pierre Trudeau and Jean Chretien — are the natural party of government in Canada, and to redefine what it means to be Canadian.

Hurt when Canada entered a mild recession earlier this year, Harper made a controversy over the Islamic face veil a focus of his campaign, a decision his opponents seized on to depict him as a divisive leader.

“Canadians rejected the politics of fear and division,” New Democratic Party leader Tom Mulcair said of the Harper Conservatives.

Liberal leader Justin Trudeau plays with son Hadrien as he watches the election results with his wife Sophie Gregoire, son Xavier and daughter Ella-Grace at a hotel in downtown Montreal on Monday, Oct. 19, 2015. —AP

Nelson Wiseman, a political science professor at the University of Toronto, said Canadians rallied around the Liberals as the anti-Harper vote.

The New Democrats suffered a crushing defeat, falling to third place after winning official opposition status in the last election. “I congratulated Mr. Trudeau on his exceptional achievement,” Mulcair said.

Paula Mcelhinney, 52, from Toronto, voted Liberal to get rid of Harper.

“I want to get him out, it's about time we have a new leader. It's time for a change,” she said.