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.

“Tonight Canada is becoming the country it was before,” Trudeau said.

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, 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.”

Liberal Party leader Justin Trudeau, accompanied by his wife Sophie Gregoire, celebrate his victory with supporters. (Chris Wattie/Reuters)

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.

Justin Trudeau first captured national attention in 2000 with a moving eulogy at his father’s state funeral. He challenged the country to cement Pierre Trudeau’s vision of a united and multicultural Canada, moving many people to tears.

“It’s all up to us, all of us now,” he said then.

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

Trudeau, who has reenergized 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.

The Trudeau victory will ease tensions with the United States. Although Trudeau supports the Keystone pipeline, he argues that 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 of his colleagues to make a cheerleading pyramid, his campaign plane in the backdrop with “Trudeau 2015” painted in large red letters.

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

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

Paula Mcelhinney, 52, of 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.

But Harper’s “protect our economy” message resonated with Anne Collis, 61, of Toronto.

“I normally vote Conservative, but this election I wavered between him and the other parties because Harper can be a bit of a bully,” Collis said. “But, in the end, I like what he’s done.”

— Associated Press

Read more:

Quiz: What do you actually know about Canada?

5 things the U.S. could learn from Europe

Today's coverage from Post correspondents around the world