For the past several years, NATO ally Turkey has churned with political turmoil, stemming from the war next door in Syria, the fallout from a violent coup attempt and a series of hard-fought elections that President Recep Tayyip Erdogan has used to accumulate power and burnish his tough-guy image.

Sunday’s vote for local offices throughout the country, the Trump administration hopes, will be followed by a period of domestic calm that will allow progress in resolving major bilateral conflicts that have been stalled for months.

One problem is Turkey’s purchase of a top-line Russian missile defense system, the S-400, that the United States and NATO have said is “incompatible” with the alliance and that is likely to result in the cancellation of the pending sale of 100 U.S. F-35 fighter jets to Ankara. Erdogan insists the Russian deal will go forward, and delivery is scheduled to begin this summer.

“We’re trying to get to the end of the elections, because one could imagine . . . a whole lot of things to talk about,” said a senior administration official, one of several who spoke on the condition of anonymity to discuss planning and diplomatic issues.

But time is running out.

U.S. plans to withdraw troops from Syria have been complicated by Turkish threats to launch a cross-border offensive against tens of thousands of Syrian Kurdish fighters who have been American allies in the campaign against the Islamic State. Erdogan considers them terrorists; the administration has vowed to protect them.

President Trump backtracked on his December announcement that all 2,000 U.S. service members in Syria were leaving immediately and agreed last month that 200 could stay in the northeastern region from which the Islamic State has been routed. A U.S. official said that plans are for the withdrawal, which has not started, to “hover” at a “plateau” of about 1,000 troops for an undetermined period of time, before eventually falling to 200.

About 200 additional troops are expected to remain in the south, at a garrison along Syria’s border with Jordan.

But there were indications of continued confusion and uncertainty, even within the military, about the path ahead in Syria. A spokesman for the chairman of the Joint Chiefs of Staff, Gen. Joseph F. Dunford Jr. — who earlier this month called “inaccurate” a Wall Street Journal report saying that the United States was planning to keep a total of 1,000 troops in Syria — said that “there has been no change to the plan announced in February.”

“We continue to implement the President’s direction to draw down U.S. forces to a residual presence in a deliberate and coordinated manner,” Col. Patrick Ryder said in an email. “To ensure campaign continuity, we’re continuing to work closely with our allies and partners in the region to develop and refine the support required for the stabilization phase” of the counter-Islamic State campaign in Syria. “This work is on-going and, for operational security reasons, we will not discuss specific U.S. troop numbers or drawdown timelines,” Ryder said.

Turkey remains a major factor in the indecision. Britain and France, with their own troops on the ground in Syria, have said they will not stay if the United States withdraws. But U.S. efforts to develop a plan have been on hold while the administration negotiates with Turkey.

All agree that some kind of counterterrorism force needs to remain to root out thousands of disbursed militants and ensure they do not regroup. Trump has also agreed with Erdogan, however, that a militarily protected “safe zone” will be established in Syria along the Turkish border to prevent Kurdish incursions and has said an “international force” will undertake the task.

Neither the Pentagon nor Britain or France are interested in being part of such a force, and all three have legal prohibitions on deploying their troops in Syria for anything other than fighting the Islamic State.

Another senior U.S. official said an “international” force to secure the zone is not in the cards. Instead, the latest idea is that Kurdish fighters from the People’s Protection Units, or YPG — which make up the bulk of the U.S. partner forces on the ground in Syria, called the Syrian Democratic Forces — “would withdraw” from the border.

“The issue of who, beyond locals,” would secure and patrol a 20-mile-wide zone “is not worked out,” this official said.

No one, least of all Turkey, has yet agreed to this concept. Kurdish leaders who are part of the SDF have said they are willing to open a dialogue with the Syrian government of President Bashar al-Assad and with Russia, his main backer, about joining forces.

Despite the optimism of some, other U.S. officials fear the U.S.-Turkey relationship might get worse after Sunday’s elections. Conversations about the safe zone have made little headway, and with no agreement, Turkey could take unilateral action.

No matter what happens, the elections are unlikely to dent Erdogan’s hold on power. But he has campaigned relentlessly for his party’s candidates ahead of a poll that many see as a referendum on his leadership, and especially his management of the economy, which has slipped into recession for the first time in a decade after years of steady growth.

As he has crisscrossed the country to rally core supporters, Erdogan has used populist and sometimes incendiary rhetoric at rallies, including repeatedly replaying footage of the recent massacre at two New Zealand mosques in an apparent attempt to appeal to conservative Muslim voters.

Although Turkey manufactures key components of the F-35 fighters, Congress has threatened to cancel its planned purchase of 100 of the planes if it goes ahead with the Russian air-defense deal. NATO and the United States have said the co-location of the two in Turkey would be an intolerable security risk.

While Turkey says its defense purchases are a “sovereign choice,” one senior administration official said, “they also have made a sovereign choice many years ago to be part of the West and part of the . . . NATO alliance.”

Erdogan and other Turkish officials have left little uncertainty about their plans to take delivery of the Russian system and have dismissed U.S. offers to sell Turkey a Patriot air defense system as too little, too late.

“We have agreed with Russia in the end and signed an agreement,” Foreign Minister Mevlut Cavusoglu told reporters Friday after meeting with his Russian counterpart, Sergei Lavrov, according to Reuters. “This agreement is a done deal.”

Fahim reported from Istanbul. Missy Ryan in Washington contributed to this report.