Moscow — After months of trying, the Soviet leadership has finally managed to oust the Communist Party leaders of two important republics - Armenia's Karen Demirchyan and Azerbaijan's Kyamran Bagirov. Both men were replaced Saturday at party meetings in their respective capitals attended by members of the ruling Politburo. The timing of the dismissals gives the impression that they are Moscow's reaction to the renewal last week of ethnic unrest in the two contiguous republics. But well-informed Soviet sources say that the newly appointed party chief for Azerbaijan, Abdul Rachman Vezirov, had been aware of his appointment for several months.
This would indicate that Soviet authorities had been carefully waiting for the moment to move against Mr. Bagirov. It also indicates that Moscow was trying to avoid the ethnic rioting that followed the removal in December 1986 of Kazakh party leader Dinmukhamed Kunayev.
The dismissal of the two men was witnessed by four of the country's top leaders. The second-ranking Soviet leader Yegor Ligachev spoke at the Azerbaijan meeting, which was also attended by candidate (non-voting) Politburo member Georgi Razumovsky. In Armenia the meeting was addressed by Alexander Yakovlev, Gorbachev's closest associate in the leadership. Mr. Yakovlev was accompanied by candidate-member of the Politburo Vladimir Dolgikh.
The presence of Ligachev and Yakovlev, however, indicates that the Politburo considers the two men - who represent respectively a conservative and radical approach to reform - to be on roughly equal footing. And it also suggests that what some Soviet observers are calling ``the shaky balance of power'' between conservatives and radicals remains in force.
Bagirov and Mr. Demirchyan came in for widespread criticism after the unprecedented outburst of riots, strikes, and civil disobedience in the two republics last February. In the course of agitation over the status of the autonomous region of Nagorno-Karabakh - an Armenian enclave within the predominantly Muslim republic of Azerbaijan - over 30 people are said to have died.
But their fortunes were in decline well before the Nagorno-Karabakh affair. Soviet observers speculate that the riots may have postponed the decision to remove them. Moscow, they suggest, was unwilling to add to the confusion by dismissing the two leaders.
Bagirov's position became precarious late last year when Geidar Aliyev, his patron and fellow Azerbaijani, retired from the Politburo, ostensibly on health grounds. About the same time, expos'es of corruption in Azerbaijan began to receive considerable coverage in the national newspapers.
Demirchyan has been under a cloud since late 1984. Last year he was singled out for criticism by Mikhail Gorbachev. In January 1988 the Communist Party daily Pravda published a long list of misdeeds by the Armenian leadership, and one of his former lieutenants has called publicly for his removal. His survival this long demonstrates both the independence of regional party leaders and the care with which Demirchyan has built up his party machine.