Troops of the Vietnamese-supported Heng Samrin government appeared to have advanced to the Thai border today in their campaign to clean out a major Khmer Rouge stronghold near the Phnom Malai Hills a few miles inside Cambodia.

Intense mortar and small arms fire erupted three times during the day from just across the stream that separates the two countries. The din terrified many of the approximately 25,000 Khmer Rouge soldiers and civilians who have fled the fighting in the last three days and are camped out in appalling conditions less than a mile inside Thailand.

Following a particularly intense barrage at dusk as many refugees sat transfixed and stared silently toward Cambodia as the shells fell, Thai officials said Thai Amry units would move into the area to guard against incursions.

The Phnom Malai campaign appears to be part of the Heng Samrin government's long-predicted dry-season offensive against remnants of the Khmer Rouge army, which was driven from Penh last January.

The fighting began yesterday morning when Phnom Malai was shelled by troops believed to be from regular units of the Vietnamese army. With an estimated 30,000 people living in thatched hut settlements strung along the border, Phnom Malai was an important target for the Vietnamese.

Military analysts estimate that 3,000 of the 25,000 men and women that the Khmer Rouge army is belived to still have under arms were based in Phnom Malai.

A Khmer Rouge district headman who crossed into Thailand yesterday said today all civilians had been evacuated -- 24,404 had crossed as of this evening, he said. Khmer Rouge troops who stayed behind were engaging the Vietnamese about two miles from the border. At other points the Vietnamese had advanced right to the border.

Thai intelligence sources reported the defenders were cutting down trees to make tanks traps but knew they would not be able to hold their positions. No fight to the finish was planned, the sources said; the Khmer Rouge troops would resist for a time and then retreat into Thailand.

It is clear that many soldiers have already crossed over. Groups of healthy young men with large supplies of rice put down their bedding apart from women and children in the deserted meadows and groves where Thai troops have concentrated the refugees.

One man had hung a hand grenade around his neck, which he quickly hid when a medical officer spoke sharply to him. Several refugees said the soldiers had cached their arms in Cambodia before crossing.

By giving Khmer Rouge forces what amounts to sanctuary, Thailand runs the risk that the Vietnamese will attempt a cross-border strike. However, the Thai government belives that a Khmer Rouge government in Cambodia is preferable to one that the Vietnamese control, and Bangkok is willing to take the risk.

Meanwhile, the refugees tried to make themselves comfortable. Working closely with the group's senior cadre, Thai soliders passed out rice, canned fish and high-protein biscuits. Plastic sheeting was provided for shelter -- most refugees currently have only the shade of trees or tall grass.

Lack of medicine, not lack of food, is the major problem, several refugees said. Journalists who brought bottles of multivitamins were besieged by adults and children with outstretched hands. Sick people lay spawled by the hundreds beneath trees, some of them shivering with fever. Malaria the most common ailment.

Signs of friction between civilians and Khmer Rouge cadre were often evident. One man spoke softly in French to journalists to ask their help in escaping. Another said being in Thailand was wonderful and he did not know what he would do if Angka (the Organization, as the Khmer Rouge government is known) ordered him to return.

Thai officers say the people will be allowed to stay only until their health has improved and fighting has subsided on the other side of the border.

At dusk today the refugees had an unusual vistor -- folksinger Joan Baez who was there with a camera crew to make a film to publicize their plight.

Baez bent over an 11-year-old boy who was lying by a road untended and asked if he might be taken to a hospital. The Thai officer in charge agreed and the boy was admitted to a ward in a town some 20 miles away, one of fewer than half a dozen people the Thais have allowed to leave the group.

Men and women looked at the smartly dressed Baez with curiosity (she was surrounded by a crowd of reporter's during most of her vist) but it is doubtful any knew who she was. The group's senior cadre squatted beside a Thai officer and ignored her completely. They were interested only in the shells that began falling in Cambodia during her visit.