Image copyright Reuters

Former US president Barack Obama has endorsed Canadian Prime Minister Justin Trudeau for re-election.

Mr Obama tweeted that "the world needs his progressive leadership now" and that he hoped Canadians would back Mr Trudeau's Liberal party.

Canadians vote on 21 October and opinion polls suggest a tight race.

The Obama-Trudeau "bromance" made headlines after the Canadian PM was honoured with an official state dinner in Washington.

They continued their friendship after Mr Obama left office in 2017.

Image copyright AFP Image caption The Obamas and Trudeaus prepare to dine at the White House official state dinner

Mr Trudeau tweeted back: "Thanks my friend."

Mr Obama's tweet has attracted criticism from those who say it is "foreign interference" in Canada's election. Elections Canada, which oversees the country's elections, told the BBC that foreign citizens were welcome to express their opinion on Canada's elections.

"Whether expenses were incurred, who incurred them and for what reason would be among the factors that need to be considered before determining if undue foreign influence has taken place," said Elections Canada spokeswoman Natasha Gauthier.

Drew Fagan, a professor of public policy at the Munk School of Global Affairs, said the endorsement was "unusual".

"There is a tradition of non-intervention," he said. "The sensitivity in this case is because our ties are so close and yet the power imbalance is so great."

Mr Fagan says he cannot think of a president or former president endorsing a Canadian candidate, although President Clinton did give a forceful speech against Quebec separatism in Ottawa in 1995.

Mr Obama is very popular in Canada, and his endorsement could make a real impact on this close race, he says.

"Obama himself now could become an issue in this campaign," he said.

This is not Mr Obama's first time endorsing a foreign candidate. He endorsed Emmanuel Macron during the 2017 French election.

And while he was still in office, shortly after President Donald Trump was elected, he told media in Berlin that if he were German, he would vote for Chancellor Angela Merkel.

In 2015, during the Brexit campaign, Mr Obama told the BBC that he supported Remain, provoking outcry from Leave supporters.

Mr Obama has yet to endorse a candidate in the 2020 US Democratic primary, including his former Vice-President Joe Biden.

Mr Trudeau did not endorse any US candidate in the 2016 election.

His opponent, NDP leader Jagmeet Singh, did get a popularity boost when superstar Rihanna followed him on Instagram.