When Boris Yeltsin failed to win election as president of the Russian republic on the first two ballots, thousands of Russians wrote telegrams to their representatives in the republic's legislature, pointing out that they had sent them to Moscow not to pick another Communist Party hack, a Kremlin mouthpiece, but rather someone who could give voice to their anger.

Yeltsin won yesterday on the third ballot, as popular pressure once again propelled his 2 1/2-year odyssey of political revenge and rehabilitation. Suddenly, in a period marked by economic strife, a populist who made his comeback by attacking the leadership of his former mentor, Mikhail Gorbachev, and the privileges of the apparatchiks has taken control of the biggest republic in the Soviet Union.

Yeltsin's victory is a sharp defeat for Gorbachev -- or at least that is the way Gorbachev seems to view it. Gorbachev brought Yeltsin to Moscow nearly five years ago from the Ural city of Sverdlovsk and then fired him in late 1987 when Yeltsin stood up at a closed session of the Communist Party Central Committee to denounce such leading party conservatives as Yegor Ligachev and what he saw as the tendency of the leadership to "idolize" the party leader -- Gorbachev.

Gorbachev told reporters in Ottawa yesterday that he was "somewhat worried" about Yeltsin's victory but that he hoped his rival had spoken sincerely recently when he said he was willing to work with Gorbachev. Yeltsin "has had to adjust his policy very seriously over the past few days and has adjusted for the better," Gorbachev said. "If he is playing political games, then we might be in for difficult times. We'll have to see. Life is richer than any teacher."

Yeltsin, 59, has already played a crucial role in the five-year history of Soviet reform. As Moscow Communist Party chief and a member of the party's ruling Politburo in 1986, Yeltsin became known for firing dozens of corrupt officials and encouraging a freer press and private markets in the capital. In those first heady days of reform, Yeltsin was one of Gorbachev's closest allies in the leadership.

But Yeltsin's celebrated ideological battle with Ligachev and the rest of the leadership in 1987 helped blow apart that relationship and the monolith of traditional Communist Party discipline. Once Yeltsin's denunciations hit the rumor circuit in Moscow, the myth of party unity unraveled and the public's fury at the party intensified, a process that has led to open splits within the party and the rise of a multi-party system.

Even fellow radicals regard Yeltsin with a wary eye. They see in him a crude and clever politician possessed of no specific economic program or competence, but rather a singular talent for harnessing the frustrations of millions of ordinary people who have grown weary of Gorbachev and the failed promises of a richer life.

"Yeltsin is the radical intelligentsia's link to the narod, the people, but we all worry about him," said Galina Staravoitova, a member of the Congress of People's Deputies, the country's highest legislative body. "We are counting on him to listen to the wiser voices around him."

"I'm afraid Yeltsin is a know-nothing, a crude demagogue of low culture," said Dmitri Likhachev, a scholar of Russian cultural history who is traveling with Gorbachev to Washington. "Gorbachev has made mistakes, he has deep problems, but Yeltsin is no answer."

Last year, Yeltsin took 89 percent of the vote to win the Moscow territorial seat in the Congress. And yet the late human-rights activist Andrei Sakharov, who was considered the conscience of the country, had profound doubts about him. Before leaving for his polling place, Sakharov turned to a member of his family and confided that he would not vote for Yeltsin. According to an informed source, Sakharov said he would work with Yeltsin in the radical faction of the Congress, but he still did not trust him. "Andrei Dmitriyevich said that if Yeltsin became a demagogic disaster he wanted to reserve the right to say he hadn't voted for him," the source said.

White House officials apparently were unimpressed by Yeltsin's visit to the United States last year and his brief meetings with President Bush and national security adviser Brent Scowcroft.

"If the liberal movement in the Soviet Union depends on {Yeltsin}, then it's in big trouble," said one senior U.S. official. "He's an intellectual lightweight, a real demagogue with an enormous ego."

Just before the Russian republic's legislature opened this month, the Cinematographers' Union held a "Yeltsin evening" at which a team of adoring filmmakers showed a documentary of the politician's life. The film was as worshipful as the old films official Soviet television used to make about Politburo members. Then Yeltsin came onstage and began his anti-Gorbachev stump speech, criticizing the Soviet president for siding too often with old-guard conservatives and delaying economic reform.

Yeltsin's continuing battle with the Kremlin is the source of his popularity. The Central Committee has formed various panels to investigate Yeltsin for "campaign irregularities," and the official media often do their best to make him look foolish. When Yeltsin put on a slurred and erratic performance in a speech at Johns Hopkins University last year, Soviet television was quick to put it on the air. Yeltsin accused the government of the "old CIA trick" of slowing down the tape "by micro-seconds."

Yeltsin, for his part, has hurt his reputation in a number of bizarre incidents. He charged last year that hooded government agents had thrown him off a bridge into a river, and he warned darkly that the KGB may yet try to kill him with a mysterious ray gun that stuns the heart. "A few seconds, and it's all over," he once said.

"Yeltsin has had his foolish moments, but he is what we have," said Sergei Kovalyov, a former political prisoner and a member of the legislature of the Russian republic. "I'm just hoping that he can play a role and push Gorbachev just a little further on the road to radical reform. This is no time to stop."