MOSCOW -- The continuing saga of a West German pilot's flagrant violation of Soviet air defenses has left the Soviet military establishment vulnerable to strong public criticism, purges and increased control by Kremlin leader Mikhail Gorbachev.

By replacing old-guard defense minister Sergei Sokolov with a younger general in the wake of the incident, Gorbachev has signaled, in the view of western and Soviet analysts here, that he will exploit it to carry out a military purge that will likely include senior generals who are clinging to a hard-line position in the Afghanistan conflict and who may have opposed some of his arms control policies.

The May 28 flight West German pilot Mathias Rust took through Soviet airspace, climaxing with a daredevil landing in Red Square, has led to a breaking of the taboo against direct Soviet criticism of the military, traditionally ranked alongside the KGB secret police and the Communist Party as one of the three key Soviet strongholds of power.

In the Soviet capital, a psychological climate already seems to be setting in for beefing up civilian spending at the expense of military investments.

Last week, for instance, the minister of the massive Soviet machine-building industry was replaced by a deputy defense minister -- a move interpreted here as the latest signal of a drain of heavy industry brainpower from the military to the civilian sector.

Privately, Soviets are rebelling against traditional Kremlin calls for the public to sacrifice for the defense of the motherland. "If a West German pilot can land on Red Square," one Soviet artist said in an interview this week, "why have I been going without all these years so the Soviet borders could be secure?"

In the pages of the official Soviet news media, Soviets are challenging the status of the military just as bluntly. In the weekly Literary Gazette, for instance, Soviet academics debated whether a mandatory draft is really necessary. Other party organs have leveled criticisms against such sacred cows as Soviet military academies and Joseph Stalin's leadership during World War II.

The military apparently is bracing for a fight, however, using the official media to beat back arguments against eliminating the draft and charges of elitism among senior military officials.

When senior Soviet officials summoned the international press to introduce a book about the new Soviet leadership's peace policies this week, a correspondent for the military newspaper Red Star asked whether release of the book closed off the possibility for Soviet officials to debate the peace policies espoused in it.

To an American correspondent in the Soviet capital who lacks direct access to discussions between military and political officials, such questions indicate a major tug-of-war developing between them over such essential questions as the reduction of defense spending and the necessity of shifting resources to the civilian economy.

Also at issue is the fate of some senior military officials, particularly the four top marshals who western analysts say were passed over two weeks ago when Gorbachev promoted Dmitri Yazov, 63, a middle-ranking general with no ties to Moscow's circle of military leaders, to replace Sokolov as defense minister.

They include the following:Victor Kulikov, 65, commander of the joint forces of the Warsaw Pact since 1979. Kulikov has espoused the theory that nuclear war is not outside the realm of possiblity, a view at odds with Gorbachev's position that a nuclear war cannot be won.Petr Lushev, 64, an Army general. Lushev, believed to be the key candidate for defense minister before the shake-up, was promoted to deputy defense minister a year ago and had assumed many of Sokolov's duties during his recent illnesses.Nikolai Ogarkov, ousted 2 1/2 years ago as first deputy defense minister and chief of the general staff in what was believed to be a dispute over military investments. Ogarkov, 70, favored increased spending in high-tech conventional weapons, a policy that would likely increase defense spending rather than reduce it, as the Gorbachev leadership proposes.

Western and Soviet military experts expect all three to be retired in the shake-up of military officials.

The fate of Sergei Akhromeyev, chief of the general staff of the Army and the senior military specialist in international affairs, is uncertain. It was Akhromeyev, 64, who sounded a critical note about the results of the 1985 U.S.-Soviet summit after Gorbachev returned to Moscow from Geneva.

All four are among the 18 senior military officials who are full members of the 307-member Central Committee, however, and could use the meeting of the powerful body planned for late this month to buttress their positions.

Yazov is a candidate, or nonvoting, member of the Central Committee.

Along with other senior military officials of an older generation, those passed over are thought to have cautioned the Kremlin against political compromises in bringing an early end to the eight-year-old Soviet-backed war in Afghanistan.

The involvement of some 115,000 Soviet troops in the war has long provided the only possibility for Soviet soldiers to gain experience in active duty.

Besides manpower, the biggest issue facing the new military leadership is spending.

Although Gorbachev has said that he favors shifting resources from armaments to the domestic economy, his high-profile policy of nuclear weapons reductions would yield few savings since nuclear weapons total only an estimated 10 percent of the Soviet defense budget.

Soviet defense spending rose to between 15 and 17 percent of the gross national product in 1982, compared to 12 to 14 percent in 1970, the Pentagon estimates.

Yazov appears handpicked by Gorbachev to tackle both purging and budget cutting in the military, according to western and Soviet analysts here.

He is a career officer with a reputation for taking a strong personal interest in Soviet soldiers. He attracted national attention in October 1985 when, in an article in Red Star, he advocated paying greater attention to "the human factor" in beefing up the Soviet military. The human factor is a term the new Soviet leadership uses to call for greater personal commitment in realizing its economic and political goals.

With experience as a military division leader in Czechoslovakia, the Soviet Far East and Central Asia, Yazov has established wide-ranging contacts with rank-and-file soldiers.

Like Gorbachev, he comes from outside the tightly knit circle of Moscow-based leaders.

Like Eduard Shevardnadze, the Georgian party leader Gorbachev brought from Tbilisi to be foreign minister two years ago, Yazov is seen as an outsider with a mandate to oust old leaders and usher in the so-called new political thinking.