President Trump congratulated Canadian Prime Minister Justin Trudeau early Tuesday on Trudeau's second-term win following parliamentary elections in Canada.
Trudeau, whose campaign was rocked by recent scandals, appeared set to win a second term and his Liberal party won the most seats in the 338-seat Parliament, giving it the best chance to form the next government.
"Congratulations to @JustinTrudeau on a wonderful and hard fought victory. Canada is well served. I look forward to working with you toward the betterment of both of our countries!" Trump tweeted after midnight Tuesday.
The CBC projected that the Liberals won't win the majority of seats in Parliament and will have to rely on another party to pass legislation. Not since 1935 has a first-term Canadian prime minister with a parliamentary majority lost a bid for re-election.
"It's way better than I expected. It was conceivable that the Liberals would lose," said Robert Bothwell, a professor of Canadian history and international relations at the University of Toronto. "Trudeau is going to have to command a caucus that will not be as grateful than it was in 2015. A lot of them will say `Look we won but not because of you."'
Trudeau had faced a string of controversies in the weeks ahead of the election, including a series of photos depicting the prime minister in blackface and brownface, for which he apologized. The 47-year-old was tarnished by a scandal that erupted earlier this year, when his former attorney general said he pressured her to halt the prosecution of a Quebec company. Trudeau has said he was standing up for jobs.
Trudeau reasserted the country's liberal identity in 2015 after almost 10 years of Conservative rule and has been viewed as a beacon of hope for liberals in the Trump era. The Liberal Party leader appeared on the cover of Rolling Stone magazine under the headline "Why Can't He Be Our President?"
Sensing Trudeau was in trouble, Barack Obama made an unprecedented endorsement by a former American president, urging Canadians to re-elect Trudeau and describing him as a hard-working, effective leader who takes on big issues like climate change.
"The world needs his progressive leadership now," Obama tweeted.
Trudeau's opponent, Andrew Scheer, was a career politician described by those in his own party as bland, a possible antidote for those tired of Trudeau's flash. Scheer, 40, called Trudeau a phony who can't even recall how many times he has worn blackface.
Trudeau's father swept to power in 1968 on a wave of "Trudeaumania," and while he had a scare at the polls when he ran for re-election four years later, he would lead Canada for almost 16 years, becoming a storied name in the country's history, responsible for opening the door wide to immigration.
The Associated Press contributed to this report.