A bizarre electoral upset in Russia's tiny protectorate of South Ossetia, a breakaway province of Georgia, has thrown the little republic into chaos and brought acute embarrassment to its sponsors in the Kremlin.

On the cusp of Russia's own crucial cycle of elections, the blatant crushing of an apparently legitimate election victory in a key client state of Moscow could bring a fresh wave of unwanted attention to Russia's own problematic democracy.

The trouble began last Sunday, when South Ossetia's official election commission declared former education minister and anticorruption outsider Alla Dzhioyeva decisively ahead in presidential elections, having won 57 percent of the votes with most of the ballots counted. The problem was that Ms. Dzhioyeva's opponent, Anatoly Bibilov, who was trailing far behind with 40 percent, had been personally endorsed by Russian President Dmitry Medvedev.

On Tuesday the republic's Supreme Court met behind closed doors and declared the polls null and void, citing "irregularities" that have yet to be spelled out. The decision barred Dzhioyeva from participating in any future elections.

In a move that some Russian analysts say Moscow will come to regret, Russia's Foreign Ministry subsequently issued an official statement endorsing the annulment of the election results, saying that Russia favors maintaining a "calm and stable situation" in South Ossetia.

Dzhioyeva's supporters took to the streets the South Ossetian capital of Tskhinvali on Wednesday and Thursday to protest, bringing a tough response from riot police who fired shots into the air and physically prevented protesters from approaching government buildings. The Kremlin dispatched a special emissary, Sergei Vinokurov, to the region in hopes of negotiating a solution.

"The people have spoken; 17,000 voters [out of 28,000 registered voters in the tiny republic] supported me," said Dzhioyeva, reached by telephone in Tskhinvali on Thursday. "Both the official Central Election Commission, and international election observers [including Russian ones] declared our elections to be basically free and fair. That gives us grounds to believe that we have won."

But Russia, which fought a war with Georgia in 2008 to preserve the independence of South Ossetia and another rebel republic, does not appear to see things that way.

Nor does outgoing president Eduard Kokoity, a deeply unpopular figure who unsuccessfully tried earlier this year to pressure the republic's legislature into amending the Constitution to grant him a third term of office, and then supported Mr. Bibilov as his anointed successor.

"The republic's leadership will make no concessions and will not yield to pressure," Mr. Kokoity, who rejects Dzhioyeva's victory, was quoted as saying by the official Russian RIA-Novosti agency Thursday. "I call on everyone to come to their senses and make serous conclusions."

Some Russian commentators have accused Dzhioyeva of fomenting a "colored revolution," such as the anti-Moscow revolts in Georgia, Ukraine, and Kyrgyzstan over the past decade, a charge that she calls ridiculous.

She insists that she, like most people in South Ossetia, is a Russian citizen, and would follow a strongly pro-Russian course as president.

"This is about legality," she says. "We are standing for our civil rights, and we will continue to do so."

South Ossetia, whose total population is no more than 50,000, was declared an independent state by Moscow after the 2008 war, but so far only four countries besides Russia – Venezuela, Nicaragua, and the two Pacific island nations of Tuvalu and Nauru – have recognized it.

The little republic survives mainly on subsidies from Moscow. Many experts say outgoing President Kokoity had distributed those funds to favor his own cronies and pet projects. Dzhioyeva ran, and apparently won, on pledges to make the distribution of Russian assistance transparent, and to use it to rebuild infrastructure and housing damaged in the 2008 war.

"Perhaps fresh elections, with the participation of all opposition candidates, are a way out here," says Konstantin Zatulin, director of the Kremlin-funded Institute for the Commonwealth of Independent States in Moscow.

He says many in Russia are hoping that Mr. Vinokurov, President Medvedev's emissary, will put aside narrow Kremlin interests and strive for impartiality in mediating the dispute.

"The stability of South Ossetia, and the freedom of will of its population, are higher values than support for any particular candidate," Mr. Zatulin says. "For us it's very important that Russia continues to be viewed as an honest broker in the Caucasus region. A lot is at stake."