SEOUL, JULY 9 (THURSDAY) -- The largest rally in recent years here degenerated this afternoon into a full-scale battle between South Korean riot police and demonstrators.

Clouds of tear gas filled the streets, rising five or six stories into the air, and throngs of panicked protesters and bystanders fled down back alleys. Major hotels and subway stations in central Seoul were filled with the stinging gas.

It was the first battle in the city's downtown area since the government promised free elections and other reforms two weeks ago. Before that announcement, Seoul had been the site of frequent, though usually smaller, confrontations for 20 days.

The police loosed the tear gas after 20,000 to 30,000 demonstrators left City Hall Plaza and began marching toward the U.S. Embassy and the Blue House, residence of President Chun Doo Hwan.

They had split off from what had been the largest peaceful rally in Seoul since at least 1980, a procession to honor a Yonsei University student, Lee Han Yol, who was killed by a tear gas grenade during an earlier rally.

The violence occurred after the main procession had left Seoul for Kwangju, where Lee will be buried, and after many of the marchers had departed.

The funeral rally followed the restoration by the government earlier today of the political rights of 2,300 former political prisoners, including opposition leader Kim Dae Jung, and the release yesterday of what it said were a majority of political prisoners detained since President Chun Doo Hwan came to power seven years ago.

Tens of thousands of students and sympathizers gathered at Yonsei University for a memorial for Lee, 21, the student who was killed by a police tear gas grenade. As their funeral procession wound through the streets of Seoul, thousands more men and women of all ages joined the peaceful rally.

The crowd eventually filled more than half of the expansive City Hall Plaza, and the mass of people cheered as the funeral procession passed. They then sat peacefully in front of Duksoo Palace and beneath an electric sign counting down the number of days to the 1988 Summer Olympics.

The crowd included thousands of middle-class managers and clerks who thronged into the square during their lunch hour.

"Of course I came out to see the funeral procession, but also because we have accomplished so much already," a shipping company employe said before the police action occurred. "It's so orderly, I'm proud of the people. I'm confident we can make it."

"I am a weak person, so I don't join the actual fighting," said one 30-year-old housewife carrying a baby. "But I wanted to show my support in an indirect way by watching the procession and praying for the peaceful rest of his soul."

At one point, the crowd began chanting for the Korean flag over City Hall to be lowered to half staff. No one responded, but when students managed to climb a balcony and lower the U.S. and Japanese flags over the facing Plaza Hotel, the crowd cheered and shouted, "Down with U.S. imperialism."

Shortly after noon, the funeral procession left the square and headed for Kwangju, where Lee was scheduled to be buried tonight.

Western diplomats said there could be disturbances in Kwangju, where animosity against the Chun government has run high since soldiers quelled an uprising in 1980 during which hundreds of civilians were killed.

Sizable numbers of police appeared only once during the morning and early afternoon, when an offshoot of the crowd tried to march up Sejung Avenue toward the U.S. Embassy. Police buses blocked the road, and the marchers turned back peacefully. Otherwise, student marshals controlled the crowd with virtually no police in view.

Not since 1980 had such a large crowd gathered here. Chun declared martial law two days after that May rally. He was elected in 1981 and has been in power since.

The restoration of political rights to the dissidents, who had served sentences for a variety of offenses, as well as the release of 357 convicted dissidents from jails around the nation was the first important step toward fulfilling Chun's promise of amnesty for most political prisoners.

On Monday, 177 prisoners -- including 12 prominent dissidents -- who had been in detention since last month were freed.

Although opposition leaders were not satisfied and called for more prisoners to be let out of jails, the actions were remarkable in a nation whose government had vowed only three months ago to have no dialogue with its critics until after the Olympics.

Among those freed yesterday were students involved in the occupation of the United States Information Service building in Seoul in 1985 and the Rev. Moon Ik Hwan, 69, one of South Korea's most determined dissidents during the past decade.

The education minister announced that students who had been expelled from universities for political reasons will be allowed to return after summer vacation.

Kim Dae Jung, who was sentenced to death shortly after Chun came to power in a 1980 coup, is now free to make speeches and take part in politics. His death sentence was revoked under U.S. pressure in 1981, but Kim has lived in jail, in exile in the United States or under house arrest for most of this decade.

In a telephone interview last night, Kim said that he welcomed the release of prisoners but added, "It is not enough."

"There are many noncommunist prisoners still remaining in the prison," Kim said. The government has said more prisoners may be freed, but communists and those guilty of the most serious crimes will not.

@Rev. Moon Ik Hwan, right, welcomed by his wife after release from prison.