A Soviet official was quoted today as saying that Andrei Sakharov, the country's foremost dissident, has ended his hunger strike after being told that the government would yield to his demands and allow a young woman to emigrate to the United States.

The woman, Liza Alexeyeva, 26, was summoned to the headquarters of the KGB secret police this afternoon and informed that she had been granted permission to leave the country.

She quoted a KGB official, Alexander Baranov, as saying that the decision was made yesterday and was relayed to the 60-year-old nuclear physicist and his wife. Baranov was quoted as saying that the Sakharovs ended their protest yesterday and that their condition today was "better."

There has been no other official or unofficial information about the couple, who were forcibly hospitalized last Friday after a 13-day hunger strike in Gorki, a city 250 miles east of here to which Sakharov was exiled nearly two years ago.

Sakharov had vowed that he would not end his fast until Alexeyeva is allowed to join her husband, Alexei Semenov -- Sakharov's stepson -- in the United States. His protest had resulted in widespread support from governments and scientific organizations in the West.

The decision to grant Alexeyeva permission to emigrate would represent an unprecedented Kremlin concession to the man who first developed the Soviet hydrogen bomb but subsequently became a critic of the government and symbol of the drive for human rights.

Remarks attributed to Baranov today suggest that Sakharov and his wife, Yelena Bonner, continued their hunger strike even after they were taken to the hospital, where they were presumably force-fed. The government is believed to have been under severe pressure from the Soviet scientific community as well as from various scientists throughout the world.

That it chose to relent -- and there is no reason to believe that Baranov's words were part of some ruse to get the Sakharovs to end their protest -- indicates that Moscow had decided to resolve the crisis quickly.

It is believed here that some of Sakharov's friends at the Soviet Academy of Sciences acted as mediators in reaching the resolution. The president of the academy, Anatoli Alexandrov, indicated in a conversation with Alexeyeva yesterday that he was making efforts on Sakharov's behalf.

Before she traveled to join her husband on his fast in Gorki, Sakharov's wife told journalists that she and her husband would end their fast only if told in person by trusted family friends that Alexeyeva had received an exit visa.

There was no jubilation at the Sakharovs' Moscow apartment where Alexeyeva is living. Baranov had cautioned her that the processing of her documents will "depend" on her behavior, especially in dealing with Western journalists.

"He told me that I should behave with restraint because information I was giving earlier to journalists has produced anti-Soviet feelings in the West," she said.

Baranov did not ask her not to see correspondents but only to change "the character of my relations with them," she said.

"I would very much like to see" the Sakharovs, she said, indicating, however, that she would not insist on going to Gorki.

Sakharov's victory has not been without cost. It is not yet clear what damage the protest did to his health, but it is clear that his reputation in the Soviet Union has suffered considerably because he chose to make a stand on what is seen here as a minor issue involving members of his family rather than on broad moral and political positions that he first raised in criticizing Kremlin policies in 1968.

And yet, if there is one man in this country whose accomplishments, intelligence and strength of character would permit such a challenge to be mounted with even dim hopes of success, it is Sakharov. Over the years he has been awarded more honors than virtually any other Soviet scientist. He received the 1975 Nobel Peace Prize for his human rights activities.

As far as scientists here can remember, Sakharov is the only man to be elected full member of the academy without having completed his Ph.D. He was 32 years old at the time.

His preeminent standing in Soviet science -- and more than 20 years of work in developing Soviet military might -- made his hunger strike an especially complex issue for the authorities. His high reputation in the West is also a factor.

The last thing the Soviets wanted at a time when they are assiduously courting Western public opinion is to have a man of such eminence die on a hunger strike.

If it has indeed decided to dispose of the crisis by allowing Alexeyeva to travel to the United States, the government appears to have achieved some important objectives. Since both Sakharov and his wife are bound to be treated in a hospital for some time, they would be isolated from Moscow and the rest of the world.

Moreover, the Sakharovs, who have been married for 11 years, have been separated. Because of rigid rules in Soviet hospitals, men and women are segregated.

Bonner is viewed in some quarters here as having been a "bad" influence on the physicist. Bonner had been an active dissident long before she met Sakharov. It is believed that under her influence he was led toward taking more radical positions and becoming increasingly critical of the government. The authorities now hope that his friends may be able to "reason" with the physicist and have him modify his views.

Sakharov was removed from Soviet nuclear weapons work in 1968 after publishing an essay that sharply challenged Soviet intellectual and political rigidities. Since then, he gradually became involved in Soviet dissident life. After his marriage to Bonner in 1970, he organized an unofficial committee for human rights. Since the expulsion of writer Alexander Solzhenitsyn in 1974, he has been the most important symbol of the dissident movement.

Some diplomats here speculated that the Sakharov problem, in the end, will not be solved by Alexeyeva's exit and that the authorities may yet exile the couple as they did Solzhenitsyn. But Soviet observers say this in an unlikely solution. Sakharov's works on theoretical physics continue to be published here despite his exile in Gorki and frequent press attacks on him.

Since they were spirited off to an unidentified hospital last Friday, there has been no reliable information about the couple. Alexeyeva was briefly detained on Saturday when she attempted to travel to Gorki to visit them. She was warned by the security police that she must not try to make contact with them.

On Monday, she attempted to inquire about her application for an exit visa but was told that the person handling her case was ill.

Yesterday, however, she managed to talk with Alexandrov and was also received by Baranov amid indications of a softer official line toward the scientist.

Today, Alexeyeva, a mathematics student, was summoned by a messenger to appear at KGB headquarters at 3 p.m.

"I have been authorized to tell you," she quoted Baranov as saying, "that yesterday you were granted permission to leave the country. Sakharov was informed of it, and he ended his hunger strike yesterday. He is feeling better today."

Said Alexeyeva later, "If all this is true then the authorities have decided to solve the matter in the simplest way."