MOSCOW — Despite significant tensions over a Russian troop buildup at the Ukrainian border, U.S. diplomats overcame a months-long standoff with the Kremlin on the granting of visas for U.S. Embassy personnel in Moscow during a meeting with Russian counterparts in Vienna, said U.S. officials familiar with the matter.

The agreement — which still needs to be finalized — comes after years of diplomatic tit-for-tat retaliations that have left the embassy badly understaffed, down from 1,200 personnel five years ago to just 120 now.

If enacted, the breakthrough could stave off a dire situation forecast by U.S. officials in which the embassy would be all but shuttered and would no longer support core diplomatic functions such as sending cables to Washington informing it of the political, economic and security situation in Russia, officials said.

It would also allow for an end to the U.S. mission’s current “authorized departure” status, a type of voluntary evacuation for the family members of diplomats ­­in Russia and non-emergency ­direct-hire employees.

The teams of U.S. officials, led by Deputy Assistant Secretary of State Christopher Robinson, negotiated the framework agreement during a meeting Nov. 17 with Russian envoys and plan to meet again this month to finalize the agreement, the officials said. They spoke on the condition of anonymity to discuss sensitive internal personnel matters.

U.S.-Russia relations have deteriorated severely in the past year over a range of issues including Russia’s troop buildup along the Ukrainian border, alleged Kremlin interference in U.S. elections, malign cyberactivity and sanctions over the treatment of opposition figure Alexei Navalny, who was poisoned last year and later imprisoned.

After a meeting between Secretary of State Antony Blinken and his Russian counterpart, Sergei Lavrov, in Stockholm on Thursday, Blinken warned of “serious consequences” for Moscow if it takes military action against Ukraine. Western officials have raised alarm about what they say is nearly 100,000 Russian troops posted near the countries’ border. 

Lavrov said there have been “expert consultations” on the countries’ respective diplomatic missions. But he accused Washington of not being willing “to take constructive steps.” Moscow’s requests include the return of the two diplomatic compounds, outside New York and on Maryland’s Eastern Shore, that were seized by the United States in 2016. U.S. officials alleged those properties doubled as spying outposts.

“It would be ideal just to zero all these restrictions and go back to normal, respectful functioning of our diplomatic missions,” Lavrov told reporters in Stockholm.

The United States last year permanently closed its consulate in Vladivostok in Russia’s Far East and temporarily suspended operations at the consulate in Yekaterinburg, just east of the Ural Mountains.

In May, Russia banned the embassy from employing foreign nationals when it designated the United States an “unfriendly” country. That led to the embassy having to lay off more than 200 staff members.

Then in August, the U.S. Embassy in Moscow suspended visa and other consular services.

In the latest diplomatic dispute between the countries, Russia’s Foreign Ministry on Wednesday ordered U.S. Embassy staff who have been working in the country for more than three years to leave by the end of January.

Foreign Ministry officials said the move was in retaliation for Washington ordering 55 Russian diplomats to leave — 27 by Jan. 30 and 28 by June 30 — because they’ve been in the country for longer than a new three-year limit.

The United States informed Russia more than a year ago that its diplomats will be subject to three-year assignments, a State Department spokesperson said, adding that Russia can replace those who are departing by assigning other members of its diplomatic corps to the positions.

“The United States approach creates greater parity in our diplomatic missions as both will rotate staff with similar frequency,” the spokesperson said.

Foreign Ministry spokeswoman Maria Zakharova likened the U.S. decision to an expulsion.

“Before July 1 next year, unless Washington waives the three-year rule and compromises, more [U.S.] workers [in Russia] will leave in numbers commensurate with the number of Russians announced by the State Department,” she said at a news conference Wednesday.

Russia’s deputy foreign minister, Sergei Ryabkov, told reporters “there still is time” to reverse course and called on Washington to allow the 55 diplomats to stay in the United States.

Ryabkov told the state-run RIA Novosti news agency last month that Russia is calling on the United States to “strengthen its presence in Moscow and send new employees so that at least consular services in Russia are provided in a more or less normal volume.”

But the U.S. administration official said that while the U.S. Embassy can have up to 455 people, “we can’t get visas for U.S. officers to travel here.”

Even if Moscow does start issuing visas to U.S. staff, the embassy is far away from resuming consular services. The more pressing need is security and compound maintenance, such as to the elevators and fire-suppression systems.

Like those of many other countries, U.S. missions abroad depend on employing foreign nationals because it is considered too costly to fill those jobs with Americans. Russia is an exception. Its embassies and consulates around the world work with exclusively Russians.

The U.S. consular section in Moscow, which used to have more than 60 staff members, is down to five people and now works only on emergency U.S. citizen services and a very limited number of other critical services.

The embassy is so shorthanded that many staff have had to take on extra jobs. U.S. Ambassador John Sullivan, for example, learned how to mix solutions to clean the restrooms and also how to work a floor buffer in case staff support further diminished during the pandemic.

The U.S. official added that it remains Washington’s “desire to have Russian students, athletes, et cetera, traveling to the United States — and vice versa. Even if we didn’t have the pandemic, which has limited travel, we’re just not able to issue the visas. We want to be able to support travel.”

Andrei Kolesnikov, an analyst at the Carnegie Moscow Center, said few Russians are able to travel abroad, so the suspension of consular services has concerned a slim portion of the population.

“The Russian Foreign Ministry exploits this topic in its propaganda, but it is only part, and not the most important part, of the permanent anti-American campaign itself,” Kolesnikov added.

Hudson reported from Washington.