SUDDENLY BEREFT of allies, Mikhail Gorbachev must decide which of his enemies to call on to save the Soviet Union and his reform program of perestroika. Eduard Shevardnadze's sudden flight from his side forces Gorbachev to focus on that unwelcome choice.

Gorbachev's effort to reform Soviet society through reason and example has exploded into open war for power and resources at virtually every level of Soviet life. The system has transformed itself so thoroughly under perestroika that it has now lurched out of Gorbachev's control. Everything seems up for grabs, and everyone is grabbing.

Gorbachev has sought to stand above the competing power centers he has leashed or unleashed -- the disgruntled army and secret police, the rebellious republics, the democratic reformers set on destroying the Soviet Communist Party that still underpins Gorbachev's rule. Playing these forces off against each other has been one of Gorbachev's favored tactics in his nearly six years in power.

But Shevardnadze's surprise resignation as foreign minister is a sharp slap in the face for Gorbachev, a scream intended to wake the Soviet president up to the reality that events have overtaken that tactical approach to governance. The silver-haired Georgian made it clear in his emotional resignation speech that it was the infighting around him -- and Gorbachev's failure to stop it -- that drove him out of the Kremlin.

The stakes involved in the power struggle in the Soviet Union have expanded dramatically in the past six months. The important fight is no longer at the center, between the Communist Party ideologues and those Shevardnadze hailed in his speech as "comrade democrats". The reformers have basically won that battle, bringing to Moscow a freedom of speech, association and market activity that would have been unthinkable even a year ago. In Moscow last week, it seemed at times that criticizing the Soviet president has become a form of social greeting like asking how the family is. Getting through that ritual permitted conversation to proceed to other matters.

Intellectuals, middle-level officials and journalists I spoke with in the Soviet capital indicated by both word and deed that the civil society that has come into being in the Soviet Union with encouragement from Gorbachev no longer looks to the authorities for guidance, much less permission, on political or artistic activity. A crackdown on Shevardnadze's "comrade democrats" would serve no useful purpose for Gorbachev or any other Soviet leader.

"There is no way to put the genie back in the bottle even if we wanted to," said Valentin Falin, the head of the international department of the Communist Party's once powerful but now floundering Central Committee. "Any attempt to recreate in any form the totalitarianism of the Stalin era would spell the end of the Soviet Union, the end of life as it is lived in one-sixth of the world's territory."

Falin's hyperbolic prediction underlines that the struggle today is the stuff of civil war, not simple ideological confrontation should events spin out of control.

Things have gone so badly for Gorbachev at home in this year of his Nobelity abroad that he now faces a stark choice: turning to his enemies in the army and KGB to make war on the rebellious republics if they continue to flout his authority, or making peace with those republics. That means making peace with his Russian rival, Boris Yeltsin. For the main battle today is between the central government in the Kremlin and the republics that want to dismantle the sprawling multinational state welded together by ethnic Russian ambition and Marxist ideology. All of the other conflicts -- the personal rivalries for power, the struggle over the economy between collectivists and entrepreneurs, the other ideological clashes -- are now bound together in the showdown over the territorial carving up of the historic Russian Empire.

That empire was formally converted by treaty into the Soviet Union in 1922, creating a single state that covers 11 of the world's 24 time zones. It encompasses 128 officially recognized national groups that historically have been as likely to hate each other as to be good neighbors. Tightly ruled by the Kremlin, this state was delineated into 15 republics with theoretical sovereignty over their own affairs and their dealings with the outside world.

The political and economic openings offered by perestroika and the relaxation of internal control based on terror have fanned the flames of nationalism through these republics. But Gorbachev has been reluctant to acknowledge how rapidly the fire has spread and how brightly it is burning, from the Baltic republics of Lithuania, Latvia and Estonia to Shevardnadze's native Georgia.

Three years ago a small group of Gorbachev's closest advisers prepared for him a plan that extended political and economic concessions to the Baltic republics that they hoped would win the support of the local political leaders for perestroika. The plan held out the possibility of an orderly, if distant, accession to independence for the three states.

"Gorbachev indicated that he understood and agreed with the plan," one of the advisers told an American friend recently. "But then he did nothing to make it happen. Now the Baltics are in revolt, and we wind up inheriting the worst of all consequences."

The Gorbachev group "has lost the initiative in the democratization process which it had itself triggered," says Andranik Migranyan, a political scientist. "The center has lost the possibility to influence these new structures." Shevardnadze's resignation speech, while not mentioning the nationalities question, exudes the same sense that Gorbachev lags behind events and risks being overwhelmed by them. Referring to attacks on himself from hardline members of the Congress of People's Deputy and a maneuver by one of Gorbachev's top lieutenants, Anatoly Lukyanov, that undermined the foreign minister's authority, Shevardnadze demanded: "Why is no one rebuffing them?"

The struggle over the pace of economic reform has now moved outside the Kremlin and fused with the revolt of the republics. The Baltic example has inspired others to decree their own rules of free market activity and ownership at the republic level. The most far-reaching and important changes have come, not surprisingly, in the biggest, richest and most advanced republic, the Russian Federation, which is headed by Yeltsin.

"We now have sovereign republics, and only the republics have the resources to allocate to make economic reform work," said Stanislav Shatalin, a member of Gorbachev's Presidential Council and until recently one of his top economic advisers. "The Soviet Union should stay integrated economically. But the republics can bring market reform into existence, while the center does not seem to be capable of doing it."

"The Russian parliament is not asking Gorbachev's permission to conduct economic reform," says Andrei Fedorov, the Russian Federation's deputy foreign minister. "There will be no all-union economic reform, since conditions vary so much from republic to republic. Privatization in Moscow will be different than privatization in the Central Asian republics, and we will get on with it."

Fedorov, 35, is one of a number bright young professionals who have bet their futures by moving from the center to the new republican governments in recent months. Previously a staff member of the Central Committee, he now serves under Andrei Kozyrev, who left a senior position at Shevardnadze's ministry to head Yeltsin's foreign ministry. Gorbachev has responded to the direct challenge presented by the laws the republics have passed and the economic agreements they are making among themselves by riding two horses at once. Characteristically, he hops from one to the other as circumstances require. He has flashed an iron fist at the republics with menacing speeches and the appointment of law and order figures at the top of the Ministry of Interior. At the same time, he has sought to woo some of the key republican leaders with jobs, honors and trips abroad, and has promised flexible arrangments in the new union treaty he wants to sign with them.

Diplomatic sources have firm reason to believe that Gorbachev offered the new post of Soviet vice president to Kazakstan's popular president, Nursultan Nazarbayev, but was turned down. Nazarbayev is said to have concluded that he would wield less real power at the center than he would as the head of his relatively prosperous republic which, despite Gorbachev's efforts, is increasingly pulling away from the center.

Gorbachev, determined to have a non-Russian in the post, then fastened on his Georgian ally Shevardnadze for the vice president's job despite the foreign minister's public request not to be considered for the job. By design or otherwise, Shevardnadze's resignation preempted Gorbachev's plan and establishes Shevardnadze's credibility and independence should he seek a future in Georgian politics.

Probably more to the point, the exit separates him from the central government if a violent crackdown is on the way. The heavy emphasis Gorbachev placed on law and order in his speech last Monday in opening the Congress of People's Deputies raised fears even among those who believe he is opposed to violence.

"Gorbachev's record is that he gives a tough speech to placate his hardline opponents and then turns on them when they are off guard and reduces their powers," said a senior Western diplomat. "But how many times can he bluff and get away with it? His margin for such maneuver is dwindling."

Shevardnadze seems to believe there is still time to prevent Gorbachev from adopting the iron-fist option and that the core republics of the Soviet Union can be kept together. Interestingly enough, Yeltsin and his lieutenants appear to believe the same thing. They stress that they seek no confrontation with Gorbachev now and that Russia will not leave the union.

"Yeltsin's interest is to try to reduce the power of the center but not to gut it. It would not be popular in Russia to be the cause of the collapse of the union. And some day he sees himself getting those powers, as the successor to Gorbachev," says a Western diplomat. "He will bide his time, build support and make whatever deals with Gorbachev are in his interest."

Adds Fedorov, Yeltsin's deputy foreign minister: "There will be no open confrontation. We seek consultation and cooperation instead. The time of change from the top has gone. We will pursue change at the republican level. But I suppose there could eventually be something like a coalition government with central and republican features." Despite their bitter feuding and rivalry of the past three years, Gorbachev and Yeltsin hold the key to each other's survival as Soviet politics implode. With Shevardnadze out in protest and Gorbachev's other key ally, Alexander Yakovlev, in mysterious eclipse, the Soviet president must take political allies where he can find them.

Shevardnadze's shock treatment means that Gorbachev must now consider forming a government of national salvation, which would bring Yeltsin and other reformers into a Gorbachev-headed regime. Such a government could demand the general sacrifice it will take to bring market reforms into the Soviet economy and could credibly negotiate a new union treaty with the republics. There may be no other safe path away from the brink on which Gorbachev now balances.

Jim Hoagland, associate editor and chief foreign correspondent for The Washington Post, returned last week from a trip to Moscow.