One downside to having a witless howler monkey for a president is that, even on the rare occasions when Donald Trump is fundamentally right about an issue, he still makes a hash of it.

Consider his recent squabbles with Germany over trade. After delivering an awkward speech at NATO headquarters last week in which he lectured our European allies for failing to spend enough on their own military defense, Trump reportedly griped to a room full of leaders that the Germans were “very bad” (or possibly, depending on your translation, “very evil”) for running a large trade surplus. “Look at the millions of cars they sell in the U.S. We’ll stop that,” he reportedly said. These comments were widely mocked—German companies already make many of their cars in the U.S.—but Trump nonetheless doubled down publicly on his position Tuesday morning on Twitter.

We have a MASSIVE trade deficit with Germany, plus they pay FAR LESS than they should on NATO & military. Very bad for U.S. This will change — Donald J. Trump (@realDonaldTrump) May 30, 2017

And you know what? He has a point. As usual, Trump’s comments lack any semblance of nuance, and he may only barely understand that of which he tweets. But economists have criticized Germany for years over an approach to trade that has punished its European neighbors, destabilized the eurozone, and sapped global growth. The president’s basic intuition that Berlin is a bad actor on this issue is correct.

But Trump’s public tantrum over it is almost certainly doing more harm to his cause than good.

There is arguably no country that does a better job gaming global trade right now than Germany. The country’s exports have topped its imports year after year, and in 2016 it piled up the world’s largest current account surplus—dwarfing even China’s both as a total dollar figure and as a percentage of its economy. Germans have not accomplished this feat solely because they have a knack for designing sports cars. Rather, they’ve done it by being thrifty to a fault, saving far more than they spend—which by the rules of economics ultimately leads to a trade surplus. Households in Stuttgart and Munich simply don’t buy enough imported merchandise to balance out the roadsters and turbines and prescription drugs German companies ship to the world.

You can’t blame German families for stowing money away. They’re a proudly frugal people who regard a penny-pinching housewife as a symbol of their national character, after all. The country’s population is also aging, and old folks need their nest eggs. But the savings glut that fuels Germany’s trade surplus is also a product of public-policy choices that have pitted its well-being against the world’s. Angela Merkel’s government has insisted on running a budget surplus—which this year hit a record high—which contributes to the national savings rate. Meanwhile, workers’ pay has been kept down by a combination of concessions made by labor unions and labor market reforms from the early 2000s that made it easier for companies to hire inexpensive temporary employees. Those low wages have allowed German companies to be more competitive abroad while also discouraging consumer spending at home.

None of this would be a problem if Germany still had its own free-floating currency. If it did, rising exports would drive up the Deutsche mark’s value, leading Germans to sell less and buy more from overseas. But instead it shares the euro with economically weaker compatriots like Spain and Italy, which keeps the cost of German wares artificially cheap both inside and outside Europe.

Not coincidentally, Germany’s trade surpluses have been most devastating to other members of the currency union. It’s not merely that these other countries’ manufacturers were outcompeted by German companies. It’s that countries like Greece financed their own trade surpluses with debt—often borrowed from German banks reinvesting their country’s trade bounty—that required bailouts after the financial crisis. These bailouts were approved by moralizing German officials only on the condition of an economically crushing cycle of austerity. Before right-wing nationalists like Donald Trump and the Brexiteers became ascendant, it seemed the single largest threat to Europe’s future was German-accented economics—67 percent of economists polled by the Centre for Macroeconomics and CEPR, for instance, said they agreed the country’s surpluses were destabilizing the eurozone.

But jobless workers in Athens and Andalucia haven’t been the only victims. Economists such as former Federal Reserve Chairman Ben Bernanke and New York Times columnist Paul Krugman (who won his Nobel prize for work on trade) have argued that Germany’s surpluses were a drag on the entire global economy in the post-recession years. “We are still in a world ruled by inadequate demand, and very much subject to the paradox of thrift,” Krugman wrote in late 2013. “By running inappropriate large surpluses, Germany is hurting growth and employment in the world at large. Germans may find this incomprehensible, but it’s just macroeconomics 101.” Even the U.S. Treasury got in on the act, criticizing “Germany’s anemic pace of domestic demand growth and dependence on exports” for driving up the risk of deflation in “the euro area, as well as for the world economy.”

In short, criticizing Germany on trade is not some sort of fringe position. It’s been standard among sane economists for years.

But that brings us back to Trump. The president may not even realize it, but the two things that frustrate him about Germany—its trade balance and its military budget—are connected. Germany needs to spend more to reduce its trade balance. The most obvious way to do that is through a project like mass infrastructure investment, as Merkel’s political opponents support (her party prefers tax cuts). But lavishing more money on the military, as Trump would like, would likely work as well. It’s a position that a diplomatically adroit White House could push in private and perhaps not be laughed from the room.

Donald Trump, though, is not adroit. Since the inauguration, Europeans have been apt to laugh off the Trump administration’s criticisms of Germany as ill-informed bluster, even when they were basically valid. By waffling on NATO while attempting to bully our European allies, he’s stiffened their resistance to him and allowed Merkel to cast herself as the defender of Europe in an age when Washington can’t be trusted. “We have to know that we must fight for our future on our own, for our destiny as Europeans,” Merkel said on the campaign trail after Trump’s Euro jaunt. New French President Emmanuel Macron is joining along, cozying up to Merkel while making a theatrical display of trying to destroy Trump’s knuckles. By making himself the enemy, Trump’s taken the heat off Germany and made real economic reforms there that much less likely.