Canadian lawmakers directed chants of "Four more years!" toward President Barack Obama Wednesday as he wrapped up the first speech to Parliament by an American leader in 21 years.

Obama was also greeted with a lengthy standing ovation, which prompted the president to joke that he should just "shut up and leave."

After the applause died away, Obama spoke for nearly an hour and gave an unusually politically charged address. He appeared to criticize Donald Trump without ever mentioning the presumptive Republican nominee's name.

Discussing opposition to globalization, Obama said that "politicians, some sincere and some entirely cynical, will tap [into] anger and fear, harkening back to days of order [and] national glory, arguing we must build walls, disengage, rid ourselves of immigrants to regain control of our lives."

After hitting Trump earlier in the day over his opposition to the Trans-Pacific Partnership trade agreement, Obama urged the Canadian Parliament to pass the deal, saying "it is tempting to draw a line around our borders that will give us more control. One problem: restricting trade or giving in to protectionism in this 21st century economy will not work."

Obama also turned a restatement of his endorsement of Democratic presidential candidate Hillary Clinton into a call for equal pay for women, saying, "our work won't be finished until all women are truly equal - paid equally, treated equally, given same opportunities as men."

Fox News' Lesa Jansen and the Associated Press contributed to this report.