MOSCOW, MAY 26 -- Populist politician Boris Yeltsin failed today to win a majority in the second round of legislative voting for president of the Soviet Union's largest republic. Afterward he called for direct elections for the powerful post in order to break a deadlock between his supporters and Communist Party loyalists in the new Russian congress.

Yeltsin, who has become an outspoken critic of President Mikhail Gorbachev since he was dropped from the Soviet leadership two years ago, topped the ballot in two rounds of inconclusive voting in the congress. He received 503 votes in the second round, leaving him 28 votes short of the required majority of the 1,060 Russian deputies.

The setback for the former Moscow Communist Party chief in his quest for the Russian presidency is likely to come as a considerable relief to Gorbachev, who had campaigned hard against his election. The Soviet leader had openly backed the candidacy of Alexander Vlasov, a senior Communist Party official, who withdrew from the race on Friday when it became clear that he could not win.

"If the parliament cannot decide, the decision must be made by the people," Yeltsin told a crowd of deputies and journalists in the Kremlin after today's vote. "Let the people say that in a month there should be an election for chairman or president of Russia."

The stalemate in the republic's congress, a product of public debate once unheard of in the Soviet Union, reflects the increasing difficulties the Communist leadership is having in imposing its will. Nevertheless, Yeltsin's supporters complained that the vote had been undemocratic and that the party apparatus had thwarted the people's wishes.

The presidency of the Russian republic, which is larger than all the other 14 Soviet republics put together, would provide an invaluable power base for any ambitious politician.

Yeltsin campaigned on a platform of political and economic autonomy for Russia, provoking Gorbachev to accuse him of working toward "the breakup of the Soviet Union."

Yeltsin's official opponent in the two rounds of balloting was a Communist Party hard-liner from southern Russia, Ivan Polozkov, who appears to have played the role of stalking horse for a more acceptable candidate. Most deputies expect that Polozkov will withdraw when the congress makes new nominations as it now must. Another round of voting has been scheduled for Monday.

After today's inconclusive ballot, Yeltsin's supporters predicted that the failure to elect their champion could exacerbate social tensions around the country.

"I expect strikes and demonstrations. It will be a huge problem for the parliament to go on with its work under these conditions. Yeltsin has become a symbol," said Alexander Lyubimov, the host of a popular television news show and a member of the liberal Democratic Russia bloc.

In order to get elected by the congress, Yeltsin must now strike a deal with the Communist Party apparatus on a distribution of posts in the new Russian administration. It is conceivable that he may persuade some Communist Party moderates to vote for him as president if he agrees to appoint one of them as prime minister.

"Politically, it would make sense for Gorbachev and Yeltsin to agree on a common political platform. Making an alliance with Yeltsin would give Gorbachev popular legitimacy and contribute to a national consensus for his economic reform program," said Evgeny Ambartsumov, a political scientist and progressive deputy. "Unfortunately, their conflict has become very personal."

The political drama in the Russian congress comes at a time when the government's plans for a transition to a market economy already have run into difficulty. A wave of panic buying has swept Moscow in the past few days following the announcement that food prices could double or triple beginning of next year. The price of bread will go up starting July 1.

The consumer fever has provoked a political row between the Moscow city council, which is now controlled by progressives, and the Soviet government. Communist Party loyalists walked out of the Russian congress today after Moscow's deputy mayor, Sergei Stankevich, took the floor to accuse the government of bringing the capital to the "verge of catastrophe."

Stankevich said that 18 times more flour than normal was sold in Moscow Friday as shoppers stocked up on staples. Because of the panic buying, the city authorities are banning all non-Moscow residents from shopping in the city for a two-week period starting Monday, a measure that will be greeted with dismay by inhabitants of surrounding regions.

Ambartsumov predicted that the government's reform program would be defeated in a popular referendum if Gorbachev refuses to strike a deal with Yeltsin. He drew an analogy with events in Poland in late 1988 when the Communist authorities lost a referendum on market-oriented reforms because they lacked the trust of the population.

Another way out of the present deadlock in the Russian congress would be for the Communist Party apparatus or Democratic Russia to nominate a more moderate candidate than either Yeltsin or Polozkov. One name that has been mentioned is that of Yuri Manaenkov, a Communist Party Central Committee secretary responsible for Russian affairs who has the reputation of being a liberal.

The two opposing blocs each control roughly a third of the seats in the legislature. The remaining seats are held by independents or members of the agrarian lobby who appear to have split their votes fairly equally between Yeltsin and Polozkov.

In today's voting, Yeltsin won 503 votes compared to 458 votes for Polozkov. In Friday's first round, Yeltsin won 497, with 473 going to Plozkov and 32 to a third candidate, Vladimir Morokin.

Tonight, the KGB security police took the unusual step of formally denying its involvement in an alleged assassination attempt against Yeltsin in Spain last month. The allegations were carried by a Leningrad newspaper, Smena, which reported that two planes on which Yeltsin was flying developed mysterious technical defects.

In a statement distributed by the Soviet news agency Tass, the KGB declared that it had "absolutely nothing to do" with the incident and called for an investigation into the publication of the allegations by Smena. It described the newspaper article as "an obvious deception in order to stir up public opinion."