The Pentagon is analyzing the cost and impact of a large-scale withdrawal or transfer of American troops stationed in Germany, amid growing tensions between President Trump and German Chancellor Angela Merkel, according to people familiar with the work.

The effort follows Trump’s expression of interest in removing the troops, made during a meeting earlier this year with White House and military aides, U.S. officials said. Trump was said to have been taken aback by the size of the U.S. presence, which includes about 35,000 active-duty troops, and complained that other countries were not contributing fairly to joint security or paying enough to NATO.

Word of the assessment has alarmed European officials, who are scrambling to determine whether Trump actually intends to reposition U.S. forces or whether it is merely a negotiating tactic ahead of a NATO summit in Brussels, where Trump is again likely to criticize U.S. allies for what he deems insufficient defense spending.

U.S. officials, who spoke on the condition of anonymity to comment on the unpublicized effort, emphasized that the exercise is limited to an internal exploration of options. The top military brass are not involved as yet, and the Pentagon has not been tasked with figuring out how to execute any option.

A spokesman for the National Security Council at the White House said in a statement that the NSC had not requested a Defense Department analysis of repositioning troops in Germany. But “the Pentagon continuously evaluates U.S. troop deployments,” the statement said, and such “analysis exercises” are “not out of the norm.”

Several officials suggested that Pentagon policymakers may have moved ahead with the assessment to prove the worth of the current basing arrangement and dissuade Trump from carrying the thought of withdrawal any further.

Pentagon spokesman Eric Pahon dismissed any suggestion of a full or partial withdrawal from Germany and described such analysis as routine.

“The Pentagon regularly reviews force posture and performs cost-benefit analyses,” he said in a statement. “This is nothing new. Germany is host to the largest U.S. force presence in Europe — we remain deeply rooted in the common values and strong relationships between our countries. We remain fully committed to our NATO ally and the NATO alliance.”

Since the end of World War II, the U.S. troop presence in Germany has been viewed as a bulwark against a potential Russian invasion of Europe and a staging ground for U.S. operations in Africa and the Middle East.

Defense officials said a cost analysis of options for changing that was being conducted at a staff level to inform a wider discussion about the U.S. troop presence in Europe. As part of the regular analysis of the cost and justification for its troops around the world, the United States has dramatically reduced the size of its force in Germany from Cold War levels.

But persistent doubts in Europe about Trump’s commitment to the alliance have made even the possibility of routine changes to American force posture in Europe far more charged.

The redeployment scenarios under study include a large-scale return of U.S. troops stationed in Germany to the United States and a full or partial move of U.S. troops in Germany to Poland — a NATO ally that has met the alliance’s defense spending targets and whose leadership is more in tune with Trump.

In recent months, Poland has proposed spending at least $2 billion to obtain a permanent U.S. base. The U.S. military already fields a rotating force in Poland, with other alliance members doing the same in the Baltic states, as part of a NATO effort to deter increasing Russian aggression along the alliance’s eastern flank.

European officials are hoping to emphasize Western unity at the NATO summit July 11 and 12. But Trump remains displeased that many NATO countries fail to spend at least 2 percent of their gross domestic product on defense, a target alliance members agreed to reach by 2024. The United States spends about 3.58 percent of its GDP on defense.

Although several U.S. administrations have called on Europe to spend more, Trump is particularly focused on the balance sheet. He has been especially critical of Merkel, on defense and a range of other issues.

Last week, White House frustration was on display in a contentious meeting in Washington between Trump’s national security adviser, John Bolton, and German Defense Minister Ursula von der Leyen. Von der Leyen said German budget projections called for increasing defense spending to 1.5 percent of the country’s GDP by 2024. The White House was disappointed with Germany’s efforts, according to officials.

A senior NATO official said that neither the alliance headquarters nor individual member governments had been notified of any Trump plans to raise the issue of withdrawing or repositioning American troops in Europe at the summit, although all are aware of Polish lobbying to place at least some components there. The official spoke on the condition of anonymity to discuss a member government in advance of the summit.

The official said Poland’s offer was “peanuts by comparison” to U.S. military investment in Germany, including “the value of 60 years of sunk costs in facilities” such as the Landstuhl military health complex and Ramstein Air Base.

The NATO official and others suggested that the cost analysis of the U.S. presence in Germany and a pullout option was reminiscent of Trump’s leaked request last winter for military options to go to war with North Korea, designed “to scare the living daylights out of everyone and get [North Korea] to the table.” In this case, the official suggested, the goal may be to “pile more trouble” on Merkel, while rattling the alliance in general and positioning himself as a summit spoiler.

U.S. allies hosting permanent American military footprints pay for a certain portion of the costs in various ways. Japan and South Korea, for example, make cash contributions, according to a 2013 study the Rand Corp. prepared for the U.S. defense secretary’s office, while Germany supports the U.S. troop presence through in-kind contributions such as land, infrastructure and construction, in addition to foregone customs duties and taxes.

Basing its statistics on data from 2002, the study estimated that Germany offset about 33 percent of the costs of U.S. military personnel stationed there. It is unclear how much would be saved by bringing them all home, because the United States would still be responsible for paying them, in addition to housing and other personnel expenses. At the same time, a large portion of the American troops in Germany are engaged in the U.S. military’s efforts outside Europe and simply base operations in the nation.

The U.S. military had been drawing down its presence in Europe for years before Russia’s annexation of Crimea from neighboring Ukraine in early 2014 prompted a change in posture, with Washington seeking to deter Moscow from further encroachments. U.S. and allied forces began rotating brigades through the eastern members, and the U.S. started returning equipment such as tanks and helicopters to the theater.

Trump’s disdain for the alliance — which he declared “obsolete” during his presidential campaign — has clearly been focused on Germany, and on Merkel in particular, including recent tweets saying she was losing her grip on power at home.

Bolton’s meeting with von der Leyen, and his emphasis on the bottom line, came more than a year after Trump tweeted in March 2017 that Germany owes “vast sums of money to NATO & the United States must be paid more for the powerful, and very expensive, defense it provides to Germany!”

Trump’s ambassador to Germany, Richard Grenell, has also ruffled feathers, telling a conservative news outlet this month he wants to “empower” the European right — a remark that some European governments view as threatening.

Senior House Democrats endorsed a letter this week penned by Rep. Seth Moulton (D-Mass.) calling on Secretary of State Mike Pompeo to fire Grenell. A State Department official confirmed receipt of the letter but did not comment on its contents.

As Trump has railed against NATO — describing it at this month’s Group of 7 summit in Canada as “worse than NAFTA,” the trilateral trade agreement he has also denounced — allies have been comforted by support from Defense Secretary Jim Mattis and to some extent from Pompeo.

In a Senate hearing on the State Department budget Wednesday, Pompeo spoke of “strong, united Atlantic unity,” even as “we have pushed them to increase their willingness to support NATO forces.”

Adding to the confusion of the overall U.S. message at a time when Trump is promoting better relations with Russia, Pompeo said the administration was pressuring the Europeans to maintain sanctions against Moscow, imposed over the Crimea annexation.

“It is time for them to care as much about pushing back against Russia as we do” and to “convince them that the sanction regime is important to achieving outcomes that are in the best interest of Europe,” Pompeo said.

While Trump has mused about why the alliance continues to ostracize Russia over Crimea and floated the suggestion that Russia be readmitted into the G-7, Pompeo reiterated that “we reject” Russian occupation of Crimea and Georgia and that the administration recognizes the threat Moscow poses to Eastern Europe.

The United States under Trump, he noted, had increased its funding for NATO forces rotating in the Baltic states and Poland. “I think this administration has been unambiguously tough on Russia,” Pompeo said. “I think that is indisputable.”

The Pentagon analysis of basing in Europe comes as relations between Trump and Europe have plunged over his decision to impose tariffs on steel and aluminum imports, sparking tit-for-tat measures, and to withdraw from the Iran nuclear deal, a pact viewed in Europe as a model for peaceful conflict resolution. The president’s decision to meet with Russian President Vladi­mir Putin in Helsinki on July 16 also adds a new twist to his trip to Europe, which includes a stop in London.

However, beneath statements about NATO’s unity and indispensability — and the alarm over Trump — the alliance is arguably undergoing a tectonic shift, and Trump may be as much its manifestation as its cause. Having lost its initial reason for being with the end of the Cold War, it found new justifications for existence during the Balkan wars of the 1990s, followed by a focus on Afghanistan and counterterrorism. The resurgence of Russia as a threatening force in Europe recently has endowed the alliance with renewed purpose.

But the question of where the Western defense pact fits into a 21st century in which Europeans disagree among themselves, as well as with the United States, on economic, trade and immigration issues, and in which the world is undergoing a basic realignment with the rise of Asia, has led some to consider a new arrangement.