The Trump administration came under fire Thursday after President Trump delivered a fundraising speech in which he railed against U.S. allies as untrustworthy and boasted that he had made up information about the U.S. trade deficit in a meeting with Canadian Prime Minister Justin Trudeau.

In a 30-minute speech to donors in Missouri, Trump made a blistering attack against the European Union, China, Japan and South Korea, accusing them of ripping off the United States for decades and pillaging the U.S. workforce, according to a recording of the private event obtained by The Washington Post. He also seemed to threaten to pull U.S. troops stationed in South Korea if he didn’t get what he wanted on trade with Seoul, an ally.

Trump and White House officials on Thursday defended the off-the-cuff remarks, which come as the administration seeks to renegotiate major trade agreements, impose tariffs on steel and aluminum imports and engage in high-stakes negotiations with North Korean dictator Kim Jong Un.

“The president was accurate because there is a trade deficit and that was the point he was making,” said White House press secretary Sarah Huckabee Sanders, who later referred to a figure that includes only goods and not services. “He didn’t have to look at the specific figures.”

Some of Trump’s most pointed remarks were aimed at Trudeau, saying he insisted to the Canadian leader that the United States runs a trade deficit with its neighbor to the north without knowing whether it was true.

“Trudeau came to see me. He’s a good guy, Justin. He said, ‘No, no, we have no trade deficit with you, we have none. Donald, please,’ ” Trump said, mimicking Trudeau, according to audio of the private event in Missouri obtained by The Washington Post. “Nice guy, good-looking guy, comes in — ‘Donald, we have no trade deficit.’ He’s very proud because everybody else, you know, we’re getting killed.

“ ... So, he’s proud. I said, ‘Wrong, Justin, you do.’ I didn’t even know . . . . I had no idea. I just said, ‘You’re wrong.’ You know why? Because we’re so stupid.”

Then, Trump claimed that a staffer told him he was correct. ‘Well, sir, you’re actually right. We have no deficit, but that doesn’t include energy and timber . . . . And when you do, we lose $17 billion a year.’ It’s incredible.”

In fact, the Office of the United States Trade Representative says the United States has a trade surplus with Canada.It reports that in 2016, the United States exported $12.5 billion more in goods and services than it imported from Canada, leading to a trade surplus, not a deficit.

In response to this story, Trump on Thursday went on Twitter to reiterate his assertion. “We do have a Trade Deficit with Canada, as we do with almost all countries (some of them massive),” he tweeted. “P.M. Justin Trudeau of Canada, a very good guy, doesn’t like saying that Canada has a Surplus vs. the U.S. (negotiating), but they do ... they almost all do ... and that’s how I know!”

In Ottawa, Canadian government spokesmen repeated U.S. government statistics pointing out that Canada has a trade surplus with their American neighbor.

“Canada and the United States have a balanced and mutually beneficial trading relationship,” said Adam Austen, a spokesman for Canadian Foreign Minister Chrystia Freeland, pointing to official U.S. statistics.

The Canadian ambassador to Washington, David McNaughton, tweeted a similar message, adding that the figure included energy and lumber — countering Trump’s insistence otherwise.

Bruce Heyman, U.S. ambassador to Canada under President Obama, wasn’t as charitable.

The president was in Missouri on Wednesday night to raise money for Josh Hawley, who is taking on Sen. Claire McCaskill (D) in November’s midterm election. He called McCaskill “bad for Missouri and bad for the country,” but he barely spoke about Hawley. Instead, he talked about himself — bragging about his 2016 election win and lavishing praise on himself while ticking through a list of U.S. allies that he said are taking advantage of the United States.

He described the North American Free Trade Agreement as a disaster and heaped blame on the World Trade Organization for allowing other countries to take advantage of the United States on trade.

He said South Korea had gotten rich but that U.S. politicians never negotiated better deals. “We have a very big trade deficit with them, and we protect them,” Trump said. “We lose money on trade, and we lose money on the military. We have right now 32,000 soldiers on the border between North and South Korea. Let’s see what happens.”

“Our allies care about themselves,” he added. “They don’t care about us.”

Trump spoke as his White House tried to pick up the pieces after a special election in a western Pennsylvania congressional district that Trump won by 20 points in 2016. Pollsters said the results showed how Trump was dragging down the Republican Party, but the president took none of the blame. He said the Republican candidate, Rick Saccone, would have lost by a wider margin without his support — Trump held a rally for Saccone over the weekend. And he said the Democrat, Conor Lamb, won the seat because he was “like Trump” but that Lamb would vote with House Minority Leader Nancy Pelosi (D-Calif.).

Trump also portrayed his decision to meet with North Korea’s leader in coming months as making history and besting his predecessors while lamenting his media coverage.

“They couldn’t have met” with Kim, he said, after mocking presidents Barack Obama and George W. Bush. “Nobody would have done what I did.”

“They say, ‘Maybe he’s not the one to negotiate,’ ” he said, mocking the voice of a news anchor. “He’s got very little knowledge of the Korean Peninsula. Maybe he’s not the one . . . . Maybe we should send in the people that have been playing games and didn’t know what the hell they’ve been doing for 25 years.”

He also railed against China’s trade practices and, in one puzzling anecdote, accused Japan of using gimmicks to deny U.S. auto companies access to its consumers.

“It’s called the bowling ball test; do you know what that is? That’s where they take a bowling ball from 20 feet up in the air and they drop it on the hood of the car,” Trump said in reference to Japan. “And if the hood dents, then the car doesn’t qualify. Well, guess what, the roof dented a little bit, and they said, nope, this car doesn’t qualify. It’s horrible, the way we’re treated. It’s horrible.” It was unclear what he was talking about.

His comments were among his most protectionist to date and didn’t identify a single benefit the United States receives from its trading relationships.

The “free-trade globalists,” he said, are against his trade moves because “they’re worldly people, they have stuff on the other side.” Gary Cohn, the president’s top economic adviser, recently quit over the tariffs and was derisively labeled by his critics as a globalist.

Alan Freeman in Ottawa and Erica Werner in Washington contributed to this report.