U.S. President Barack Obama handed the torch of progressive politics to Prime Minister Justin Trudeau Wednesday in a warm, rousing speech to Parliament, in which he also bluntly urged Canada to spend more on defence to meet its international obligations.

He praised the extraordinary alliance and deep friendship between Canada and the United States.

"We see ourselves in each other and our lives are richer for it," Obama said.

"The enduring partnership between Canada and the United States is as strong as it has ever been and we are more closely aligned than ever before."

The American president reserved heartfelt mention for Trudeau, who he said has brought "new energy and hope" to the cross-border relationship.

"My time in office may be nearing an end, but I know that Canada and the world will benefit from your leadership in the years to come."

But he also included pointed comments on a perennial sore spot, one that has taken fresh urgency in the face of a resurgent Russia and rising Islamic extremism.

"As your NATO ally and your friend, let me say, we'll be more secure when every NATO member, including Canada, contributes its full share to our common security," Obama said to sustained applause from both Liberals and Conservative MPs and senators, who returned from summer break for the historic event.

U.S. President Barack Obama is greeted by a standing ovation in the House of Commons in Ottawa on Wednesday. (Adrian Wyld/Canadian Press)

"Because the Canadian Armed Forces are really good. And if I can borrow a phrase, the world needs more Canada. NATO needs more Canada. We need you."

Washington has been ratcheting up the pressure on Ottawa to spend more for two years, ever since Russia annexed Crimea and set off a shadow war in eastern Ukraine.

At the moment, Canada spends just under $20 billion on defence — or 1 per cent of its gross domestic product, which is half the NATO standard.

Obama: 'The world needs more Canada' 1:21

The Trudeau government has also waffled on a call by NATO to contribute to a high-mobility brigade destined for eastern Europe as a deterrence measure.

Although the federal government has privately expressed interest, it has yet to formally declare this publicly.

Obama's remarks will put more pressure on the Liberal government for a public pronouncement.

His appearance on the floor of the House of Commons, alongside Trudeau and his wife, Sophie Gregoire Trudeau,was greeted with a thunderous ovation.

"It tempts me to shut up and leave. It can't get any better than this," he said, as usual decorum was abandoned and MPs snapped photos with their phones.

But the American leader, noted for his eloquence, did not disappoint.

Obama on the values of great countries 1:24

"From this vibrant capital we can look upon a world that has benefited enormously from the international order that we helped build together. But we can see that order increasingly strained by the accelerating forces of change," he said.

​But the economic values of market-based liberal economies are stronger than one event, such as the exit of Britain from the European Union.

The world is more prosperous than ever before, but Obama said it's witnessing a troubling rise in wage stagnation and inequality.

"If the benefits of globalization accrue only to those at the very top, if our democracies seem incapable of assuring broad-based growth and opportunity for everyone, then people will push back out of anger or out of fear," he said.

His progressive message of racial tolerance, social equality and justice, which is routinely and often vehemently challenged in his own his country, was embraced enthusiastically.

Trudeau, in his opening remarks, left no doubt he looked up to Obama.

"History books will record the signature policies. What I will remember; what I hope we all will remember are the lessons you taught us, not by executive order, but by example," he said.

Obama and Trudeau greet kids on Parliament Hill 2:13

Provinces in the House

The speech was watched closely by Canada's resident political and even entertainment establishment.

MPs, senators and even singer Nelly Furtado were among the invited guests.

Premiers from Alberta, Quebec, Ontario, Manitoba and the Northwest Territories were there.

That's not surprising, since those provinces and the territory are likely among the most affected by Obama's signature environmental initiative.

There were light-hearted moments earlier in the day as two leaders met with Mexican President Enrique Pena Nieto.

The president gave a discreet thumbs-up to reporters at the closing news conference when Trudeau ribbed Obama about repeated references to his impending "retirement" from public office.

Before that, as photographers snapped the family photo-op outside the National Gallery, the trio turned an awkward three-way handshake into a light and breezy moment.

.<a href="https://twitter.com/CanadianPM">@CanadianPM</a> <a href="https://twitter.com/POTUS">@POTUS</a> & <a href="https://twitter.com/EPN">@EPN</a> take a break during <a href="https://twitter.com/hashtag/NALS2016?src=hash">#NALS2016</a> for a quick photo-op in front of <a href="https://twitter.com/hashtag/Parliament?src=hash">#Parliament</a> Hill <a href="https://twitter.com/hashtag/cdnpoli?src=hash">#cdnpoli</a> <a href="https://t.co/ck3g5U0Tpt">pic.twitter.com/ck3g5U0Tpt</a> —@CPAC_TV

Rich tradition

Friendships between leaders may come and go, but speeches to Parliament by American leaders have, over the decades, developed their own groove.

Former U.S. president John F. Kennedy addressed Parliament in 1961. (Ted Grant)

They hit all of the important symbolic points in the relationship between the two countries and may never have been as elegantly expressed as they were in John F. Kennedy's May 17, 1961, address.

"Geography has made us neighbours. History has made us friends. Economics has made us partners. And necessity has made us allies. Those whom nature hath so joined together, let no man tear asunder."

It was a theme that Justin Trudeau's father picked up 20 years later when he introduced the newly elected Ronald Reagan to the House of Commons.

"Our being neighbours is not simply a matter of geography, it is a state of mind," said Pierre Trudeau on March 11, 1981.