Joe Biden's speech was applauded by the members of the Canadian parliament despite the American president mistakenly referring to Canada as China while praising lawmakers for a new deal to slow migration.
"In the United States we're expanding legal pathways for migration to seek safety on a humanitarian basis, while discouraging unlawful migration that feeds exploitation and human trafficking," Mr Biden said on Friday.
"So today I applaud China for stepping up. Excuse me, Canada. I applaud Canada," the president added as members of the parliament broke into laughter.
"...you can tell what I am thinking about China, we won't get into that yet."
Shortly after the gaffe, Mr Biden’s Republican opponents tore into the president.
“What an embarrassment to the United States of America,” wrote former president Donald Trump’s son Eric.
“Biden ‘accidentally’ praises China when addressing the Canadian Parliament. China is on his mind, and the White House knows why,” wrote congressman Byron Donalds.
Mr Biden and Canadian prime minister Justin Trudeau presented a united front just days after the leaders of China and Russia held a Moscow summit.
The leaders announced a plan to close a loophole in an immigration agreement that has allowed thousands of asylum-seeking immigrants to move between the two countries along a back road linking New York state to the Canadian province of Quebec.
Several migrants since early 2017 have walked into Canada on Roxham Road outside Champlain, New York, that the Royal Canadian Mounted Police staffed a reception centre to process them, less than five miles from the official border crossing.
Mounties have warned the migrants at the end of the narrow two-lane road bordered by forests and farm fields that they would be arrested if they crossed the border. But once on Canadian soil, they have been allowed to stay and pursue asylum cases that can take years to resolve.
The new policy says that asylum seekers without US or Canadian citizenship who are caught within 14 days of crossing anywhere along the 3,145-mile border will be sent back. That includes people walking on Roxham Road.
“The US and Canada will work together to discourage unlawful border crossings and fully implement the updated Safe Third Country Agreement,” Mr Biden said of the deal.
At a joint news conference with Mr Trudeau, the American president said the US had expanded alliances including with Nato, the G7, South Korea and the Quad nations of the US, Australia, India and Japan.
"We have significantly expanded our alliances," said Mr Biden. "Tell me how in fact you see a circumstance where China has made a significant commitment to Russia. What commitment can they make?"
Addressing Canada's parliament, Mr Biden said that, as Nato members, the two countries would "defend every inch of Nato territory”.
Mr Trudeau told the news conference that Ukraine was a top issue.
"Today we reaffirmed our steadfast support for the Ukrainian people as they defend themselves against Putin's brutal and barbaric invasion," Mr Trudeau said.
With inputs from agencies.