MOSCOW -- Bulgarian President Todor Zhivkov, the longest-serving leader in Eastern Europe, resigned Friday, thrusting his country into the political maelstrom sweeping the region.

Zhivkov, 78, who stepped down after 35 years in power, was replaced as general secretary of the Bulgarian Communist Party by Petar Mladenov, 53, the Bulgarian foreign minister since 1971, in a move that seems intended to promote basic political and economic reforms there.

In his first speech as party leader, Mladenov said Bulgaria has no alternative but to transform its political and economic system, though he stressed that the reforms must take place within the framework of socialism.

The official Bulgarian Telegraph Agency, reporting the changes at a Friday meeting of the Communist Party's policy-making Central Committee in the capital, Sofia, gave no reason for Zhivkov's resignation as the party leader and president. But Mladenov's speech made it clear that momentous changes are under way there as elsewhere in Eastern Europe.

Describing Bulgaria's efforts at reform so far as failures, Mladenov told the party Central Committee, "We failed to realize from the very start that in order to accomplish new tasks, we need new approaches and methods of action," according to excerpts of his speech from the Bulgarian agency and Tass, the Soviet news agency.

"It is in this that the answer lies to the questions--why has our restructuring failed to bring about the desired breakthrough, why is the economy so besieged with serious difficulties, why have some bold and original ideals been largely discredited."

He promised to make glasnost , or openness, the basis of politics in Bulgaria, and to broaden democracy.

"We should not worry nor should we be frightened by the fact that in seeking . . . correct solutions there can and surely will be pluralism in our opinions," he said.

Mladenov said the party's ruling Politburo will call a special Central Committee meeting soon for an in-depth discussion on the state of the country and the development of a comprehensive reform program.

Pressure had been rapidly mounting on Zhivkov, however, as President Mikhail S. Gorbachev broadened and accelerated political and economic reforms in the Soviet Union and other East European leaders followed--or were replaced.

Mladenov was promptly congratulated by Gorbachev in a cable that said he believes "Bulgarian Communists and all the working people in your country will . . . handle the tasks required by the radical and consistent renewal of society in the spirit of the socialist choice," according to Tass.

Mladenov, regarded by diplomats here and in Sofia as a moderate and far from a radical reformer, is believed to have come to power with a dual commitment--to reform but also for continuity--a formula intended to promote changes that are substantial and significant without relaxing the Bulgarian Communist Party's grip on the country of 9 million.

But the extent of those changes will become clear only as Mladenov begins to act on his own. As a member of Zhivkov's Politburo, he had been loyal to the party leader, though going significantly further in pressing for reform during recent party conferences. Soviet officials said they expect a party congress planned for December, 1990, to be convened much earlier.

Yet, the replacement of Zhivkov, who was formally thanked by the party for his "long, selfless service," was greeted with enthusiasm in Sofia for the sheer feeling of movement and change that it brought.

"This is one of the happiest days of my life," a leading scientist, Alexei Cheludko, at 70 a man of Zhivkov's generation, said in a telephone interview from Sofia. "The time had come for change in Bulgaria. This has given us hope for the future."

Cheludko, one of 250 Bulgarian intellectuals in Sofia's reform-oriented Perestroika-Glasnost Club, called for Western countries to help Bulgaria ensure the success of the anticipated reforms. Mladenov, he said, is "not the best man available but not the worst either."

Zhivkov had been rumored to be on his way out for more than two years--he was clearly out of sympathy with Gorbachev, with whom he had rather frosty relations--but the timing of the change in leadership surprised observers and its dynamics were unclear.

When Erich Honecker, the East German leader, was replaced last month amid massive protest demonstrations, attention shifted to Bulgaria, Czechoslovakia and Romania, the three Soviet allies in Eastern Europe that had not committed themselves to their own programs of fundamental change. Officials here repeated Gorbachev's warning to Honecker "not to be late" or timid in promoting reform.

Although Zhivkov frequently acknowledged the need for reforms in Bulgaria, he just as frequently insisted that they need not be as sweeping or fundamental as those in the Soviet Union or elsewhere in Eastern Europe and that, in fact, they had been under way since he came to power in 1954 during the liberalization that followed the death of the Soviet dictator Josef Stalin a year earlier.