Investors appeared to have gotten through to President Donald Trump about the risks posed by his designs for Greenland, as he stepped back from threatening tariffs on European allies while speaking in Davos, Switzerland, on Wednesday, according to the Associated Press.

The AP reported that Trump backed off his threat to slap punishing tariffs on eight European allies for opposing his insistence on acquiring Greenland from longtime ally Denmark. The shift came after Wall Street’s reaction to the Greenland plan contributed to serious talk within NATO about a potential rupture in the transatlantic military alliance.

Markets had seen their biggest losses since October as Trump prepared to travel to Davos for a keynote address at the World Economic Forum, the AP reported. During the speech, Trump grumbled about what he called a stock market “dip” and complained that the United States had given NATO and European nations “trillions and trillions of dollars in defense,” the AP said.

But the AP reported that, in the same speech, Trump made a first abrupt shift: he took off the table the option of using military force to take over Greenland. “I won’t do that. OK?” Trump told the packed conference room, according to the AP.

Hours later, Trump announced he was retreating from the tariffs, saying he had come to terms with NATO Secretary-General Mark Rutte on a “framework” on Greenland that “gets us everything we needed to get” if the agreement is consummated, the AP reported. The AP said Trump did not provide details on the framework’s terms.

The AP reported that Trump then appeared on CNBC just before Wall Street trading ended for the day, boasting that the framework was “going to be a very good deal for the United States” and allies. He downplayed the market’s role in the decision, saying, “No, we took that off because it looks like we have pretty much a concept of a deal,” according to the AP.

After Trump’s remarks, the AP reported that the S&P 500 rallied 1.2%, recovering about half the ground it had lost a day earlier. The Dow Jones Industrial Average and the Nasdaq Composite also rose 1.2%, the AP said.

Denmark’s foreign minister Lars Løkke Rasmussen cautiously assessed the change, telling reporters that “the day is ending on a better note than it began,” while saying details of the agreement still needed to be worked out, the AP reported. A European official familiar with the matter told the AP that NATO members had discussed a compromise idea involving Denmark and the alliance working with the U.S. to build out more U.S. bases in Greenland, but the official said it was not immediately clear whether that idea was included in the framework contours discussed by Trump and Rutte on the Davos sidelines.

The AP said Rutte, in an appearance on Fox News on Wednesday evening, offered limited specifics. Rutte said, “We agreed that he’s right, and he’s right that collectively we have to protect the Arctic regions,” and added that the U.S. would continue conversations with Greenland and Denmark to ensure that Russia and China will not gain access to Greenland’s economy or military sense, the AP reported.

The AP also reported that the market and NATO concerns were not the only factors pushing Trump to adjust his rhetoric. It said U.S. officials, speaking on condition of anonymity, had worried that Trump’s hardline stance and bellicose language toward Greenland, Denmark and other NATO allies could harm other foreign policy goals. Those officials said the focus on Greenland and earlier comments suggesting NATO could splinter were complicating Trump’s effort to form the Board of Peace, expected to be spotlighted Thursday in Davos.

European skepticism toward the Board of Peace concept was heightened after Trump’s tariff threat, the AP reported. It said some European countries declined invitations. Max Bergmann of the Center for Strategic and International Studies told the AP that European leaders “standing up and being firm defused the crisis,” while also arguing that “Trump is acting like a bully, and the only way that we’re going to have a stable relationship is if we push back,” according to the AP.

Other U.S. figures saw the episode differently. Matthew Kroenig of the Atlantic Council told the AP that “Most of the world was freaking out over these threats,” and he noted that the idea of Trump seizing Greenland seemed “more like a bluff all along,” according to the AP. Daniel Fried, a former U.S. ambassador to Poland who is now a senior fellow at the Atlantic Council, said, “It’s been unnecessarily dramatic, costly and damaging, but all the damages so far are repairable,” the AP reported, adding that continuing on the Greenland path would make that repair harder.