MOSCOW (AP) _ Chechen rebels freed up to 3,000 hostages they seized in a small southern Russian city, but took about 160 captives with them before dawn Wednesday in buses for their breakaway republic, officials said.

Government officials of Dagestan, the republic where the raid took place, accompanied the rebels to neighboring Chechnya as a guarantee of safe passage, Dagestan's Interior Ministry said.

Ministry spokesman Abdul Musayev told The Associated Press that at least six officials, including Cabinet members, and two unidentified journalists joined the rebels.

Zairbek Magomedov, duty officer at the ministry, said earlier that the great majority of the hostages were freed as a result of ``negotiations between the government of Dagestan and the terrorists.''

Magomedov estimated the number of hostages freed at up to 3,000, higher than the earlier estimate of 2,000, and said they were mostly in good shape, although some suffered from shock from the day's trauma.

About 250 rebels and the 160 or so remaining hostages left Kizlyar at around 7 a.m. in 11 buses and two trucks carrying weapons and the bodies of dead guerrillas, said Musayev, the Interior Ministry spokesman.

The convoy was expected to cross into Chechnya before midday, and head for the area of Gudermes, Chechnya's second-largest town, he said.

Officials in Dagestan said Tuesday night that rebel demands were changing constantly _ except for the call for a Russian withdrawal from Chechnya. Other demands were said to include direct talks between the Kremlin and rebel leader Dzhokhar Dudayev and the resignation of the Moscow-backed government in Chechnya.

Tuesday's raid on Kizlyar _ which left scores of dead in fighting _ was a copycat version of the June attack in which Chechen separatists seized hundreds of hostages in a hospital in the southern town of Budyonnovsk.

At least 100 people died before negotiations won the hostages' release in exchange for the guerrillas' free passage out and peace talks in Chechnya, which have since collapsed.

Moscow poured troops into Chechnya in December 1994 to reclaim the small southern republic from Dudayev. The war has killed up to 30,000 people, most of them civilians, and uprooted more than 600,000.

The overwhelming military might has given the Kremlin nominal control, but the Russians and their Chechen allies are still facing rebel attacks in and around the borders of Chechnya.

The rebels in Kizlyar were led by 28-year-old Salman Raduyev, Dudayev's son-in-law and once a senior official in Gudermes.

``We can turn this city to hell and ashes,'' the bearded Raduyev, who sported a green Islamic war band around his forehead, said in an interview broadcast Tuesday evening by Russian TV.

``Budyonnovsk and Kizlyar will be repeated again until Russia recognizes Dudayev and the Chechen republic.''

Raduyev said his fighters arrived into Kizlyar, a town of 44,000 people about 60 miles northeast of the Chechen capital, Grozny, aboard five trucks and one bus ``absolutely without any problems,'' Interfax reported.

The raid began with scattered attacks across the town and a clash with Russian troops at a local airport where the Chechens blew up two helicopters. At one point, Chechen snipers controlled a bridge across the Terek River and two apartment buildings near the hospital, reports said.

At least 23 people were reported killed: 13 rebels, five police officers and five civilians, and dozens were reportedly wounded.

The shootouts, however, appeared to be diversions allowing the rebels to herd hundreds of hostages into the four-story hospital building, in addition to about 1,000 patients and doctors who were inside.

News reports said there were 150 to 400 rebels; the rebels claimed to number 600.

Hundreds of Russian troops, including elite anti-terrorist units, ringed the hospital, which includes a maternity ward. Army forces sealed off the town. Gen. Mikhail Barsukov, chief of the Federal Security Service, was in Kizlyar to oversee the operation.

The rooms and corridors inside the hospital were packed with terrified hostages. Some were sitting motionlessly on the floor. Others, in a Russian TV broadcast, pleaded with the authorities to avoid attacking the hospital like they did in Budyonnovsk.

During the Budyonnovsk raid, Russian troops made two botched attempts to storm the hospital, later condemned by the hostages as unnecessary bloodshed. Finally, Prime Minister Viktor Chernomyrdin held televised negotiations with the rebel leader.

The wary Raduyev on Tuesday threatened to kill 10 hostages for every dead Chechen in case federal troops attempted to storm the hospital, Interfax said.

In Moscow, officials stepped up security to prevent terrorist attacks as newspapers _ and Kremlin leaders _ bitterly debated security breaches that allowed the Chechens to repeat the June surprise.

President Boris Yeltsin said his troops were caught off-guard again Tuesday.

``The border guards overslept,'' an angry Yeltsin told his Security Council. ``What have you done instead of effectively setting up outposts, building up forces and barring the rebels' way?''

The rebels on Tuesday had demanded a full Kremlin withdrawal from their secessionist republic in exchange for the hostages' freedom.

It was not clear why they decided to drop that demand, though on Tuesday some Kremlin officials threatened to use force against the guerrillas if talks between the hostage-takers and Dagestan authorities failed to produce results.

``The situation may be solved by internationally accepted anti-terrorist methods,'' Nationalities Minister Vyacheslav Mikhailov told Russian TV on Tuesday.

The negotiations in Kizlyar resumed early Wednesday, said Dagestan's deputy interior minister, Gennady Shpigun.