It is not wholly surprising to learn that Barack Obama hopes Justin Trudeau does well in next week's federal election. Most of us hope to see our friends succeed in their chosen endeavours.

But the former leader of the free world went beyond wishing a friend well on Wednesday when he decided to endorse the leader of the Liberal party of Canada.

That could have something to do with how Obama views both Trudeau's political agenda and his own post-presidential role in global politics.

Trudeau's rivals, and perhaps even some unaligned Canadian voters, might raise an eyebrow at a foreign public figure offering his opinion (though Conservative leader Andrew Scheer wasn't shy about commenting in 2016 on the United Kingdom's membership in the European Union) on a Canadian election.

But Obama might also look north and feel a slight twinge of empathy.

Four years after he came to office on lofty promises of hope and change, Obama's re-election campaign in 2012 had to fight through a sense of general disappointment. He won that fight and left behind a record that included an expansion of medicare, new regulations on greenhouse gas emissions, an economic recovery from the Great Recession and a number of other progressive reforms, but also nagging questions about whether he had somehow failed to live up to his potential.

None of his efforts prevented Donald Trump from winning the presidency. And Obama's legacy is now contested, from the political left, by potential successors who insist the Democratic party must move further and faster than Obama was able or willing to.

So if the former president is paying any attention to this Canadian campaign, he might be able to relate to Trudeau's current situation.

Obama's post-Trump approach to the world

Regardless, Obama's intervention on Wednesday fits with his emerging post-Trump approach to international politics, in which Obama has sought to use his platform and existing political capital to support like-minded leaders.

During his last trip to Europe as president in November 2016, Obama told reporters in Berlin that if he was German he would vote for Chancellor Angela Merkel — his quote was later printed on posters for Merkel's political party, the Christian Democratic Union.

Then, less than four months after leaving office, Obama recorded a video to endorse Emmanuel Macron's candidacy for the French presidency.

(For what it's worth, both Merkel and Macron went on to win their elections.)

The underlying message of those endorsements could be that national elections are no longer purely domestic affairs; that the world is in the midst of a struggle over the future direction of liberal democracy and every election is a piece of that larger conflict.

Around the same time, Obama was publicly suggesting he'd vote for Merkel, he was privately telling Trudeau — who he had already spoken of as a kindred spirit — that the prime minister would have to shoulder additional responsibility in a world where Donald Trump was president of the United States.

Obama has now endorsed the G7's three most-prominent centre-left multilateralists, a trio that stands in opposition to the populist and nationalist leaders elsewhere. But progressive and centre-left leaders have not been abundant in the three years since Obama left office. And both Macron and Trudeau have struggled to maintain public support (while Merkel will not be seeking re-election).

Safely removed from the rigours of office, Obama now has public standing to spare to the cause.

But he can also probably still remember the challenge of his own re-election.

The similarities between 2012 and 2019

In 2012, the Obama campaign sought to establish that the presidential election would be a choice between two candidates, not a referendum on the incumbent.

Trudeau's senior advisors are well-acquainted with some of the key strategists behind Obama and the Liberal campaign of 2019 has sought to emulate the idea that an election is a choice. Particularly in the closing stages of this federal election, "choice" is a word that Trudeau has emphasized, insisting that the race is between himself and Andrew Scheer.

Just as Obama's campaign in 2012 required less rhetorical poetry and more fight, so has Trudeau campaigned in less lofty tones in 2019 than in 2015.

But it was much easier for Obama to insist that the 2012 election was a choice between himself and Mitt Romney. Generally speaking, the two-party system provides for tidier choices.

The Liberals — while pursuing a broadly Obama-esque agenda focused on the "middle class" and climate change — can stress that one of either Trudeau or Scheer will be prime minister. But there's also Elizabeth May and Jagmeet Singh. Maybe neither of those leaders are likely to end up prime minister, but you can vote for an NDP or Green candidate and hope to end up with orange or green representation.

It is as if Obama was running against not just Mitt Romney, but also Bernie Sanders and Jay Inslee.

Obama's legacy and Trudeau's hold on power

But the forces that have buffeted Obama's political career and record are broadly similar to what Trudeau is contending with now.

An initial swell of enthusiasm and goodwill and then a struggle to live up to expectations. An argument from the political right that the incumbent has been a disappointing, even destructive, failure. An argument from the political left — from those that might be described as social democrats — that more needs to be done on every issue that matters.

Obama never dealt with the sort of personal controversies that have hit Trudeau over the past year — the SNC-Lavalin affair and the blackface photos. And those issues have further complicated Trudeau's ability to make a clear argument. But the American political system has its own eccentricities (Obama spent part of his first term contending with claims that he was not American-born).

Obama can insist that he made real progress. But that claim will be challenged now from both the right and the left. His re-election was a struggle and his legacy is still up for debate.

With all that in mind — and with his own brand of politics in need of defenders — Obama might have looked north and decided to do what he could to give his friend a nudge.

It is hard to know now whether the endorsement of the 44th president of the United States will have a significant impact on next week's vote.

But Obama might understand better than most that Trudeau should welcome any offer of support.