MOSCOW – Russia has invested years of effort and billions of dollars into turning Venezuela into one its closest allies in the Western hemisphere. On Thursday, Moscow was jolted by the prospect that its investment could be going up in smoke.

Russian Foreign Minister Sergei Lavrov said the opposition to Nicolas Maduro was becoming “pawns in someone else’s very dirty and criminal game.” Vyacheslav Volodin, speaker of the lower house of parliament, said that in Venezuela, “people off the street are being appointed heads of state.” Russian President Vladimir Putin’s spokesman said that “attempts to usurp power in Venezuela are illegitimate and contradict international law.”

Even by Russian standards, it was a day of furious commentary casting the United States as the sinister puppeteer illegally fomenting regime change around the world. But behind the outrage lay an uncomfortable reality: a multibillion-dollar bet on building Russian influence in Latin America suddenly looked like it could quickly go bad.

Dmitry Rozental, a scholar at the Latin America Institute of the Russian Academy of Scientists, said further instability could increase the risk that Russia will lose a total investment in the Venezuelan economy he estimated at close to $25 billion. If opposition leader Juan Guaidó – whom the United States on Wednesday recognized as interim president – gains power, Rozental said, then political and military contacts between Moscow and Caracas would be sure to decrease.

At the same time, Rozental said, a key question was still unanswered: how sharply Guaidó would diverge from Maduro’s Russia-friendly policies.

“If the pragmatic approach wins out, then I don’t think they’ll pick a fight with so important a partner as Russia,” Rozental said.

The Washington Post reported last month that Russian President Vladimir Putin in recent years became Venezuela’s patron – and poked a stick in the eye of the United States along the way. In exchange for loans and bailouts, Russia now owns significant parts of at least five oil fields in Venezuela, which holds the world’s largest reserves, along with 30 years’ worth of future output from two Caribbean natural gas fields.

Russia’s loans and credit lines alone have totaled at least $17 billion since 2006, making it Venezuela’s lender of last resort, Reuters reported. In return, Russia’s arms industry has won a multibillion-dollar customer, while Putin has gained new sway over global energy resources and a focal point of Russian influence just a three-hour flight from Miami.

As if to drive home the point, two nuclear-capable, long-range Russian Tu-160 bombers touched down outside Caracas in December. The symbolism matters because the rise of a Russia asserting its global interests is a key part of Putin’s brand at home.

Now the Kremlin’s Venezuela bet hangs in the balance. Putin’s domestic opponents quickly seized on it this week as already a lost cause.

Venezuela’s revolution means that billions of dollars “of our money that was invested over there will disappear,” opposition activist Alexei Navalny posted on Twitter. In a few months, Navalny added, Maduro will surely have a villa in the gated communities of Moscow’s Rublyovka neighborhood, favored by Russia’s ruling elite.