Witnesses said dozens of people were killed on Friday.
As night fell, gunfire died down in the streets of Andijan. It was unclear who held control in the former Soviet state's fourth-largest city of 350,000 people.
Authorities claimed that security forces had regained control of a local administration building seized by protesters, and a high-ranking Uzbek official said hostages taken by the demonstrators to use as human shields had been freed.
Andijan is near the border of Kyrgyzstan in the densely populated and impoverished Ferghana valley.
President Islam Karimov left Andijan late on Friday after overseeing efforts by security forces to re-establish order there, officials said.
"They're returning to Tashkent," an official in the presidential administration said.
Overnight, rebels seized public buildings and a prison in fighting that left at least nine dead and 34 wounded, according to the government.
The insurgents first raided a military garrison for its weapons, then stormed the city administration building before breaking into a prison where the authorities were holding the 23 men on charges that their supporters said were trumped up.
More than 2000 prisoners were released in the raid, Saidjahon Zainobidinov, spokesman of the Appelatsia rights group in Andijan, said.
Hail of gunfire
On Friday, the insurgents - using hostages as shields - tried to flee the building where they had been cornered, but were prevented from doing so by security forces, and gunfire was exchanged between the two sides, witnesses said.
Andijan is in the Ferghana valley
An AFP correspondent saw one person killed and five wounded on Friday when soldiers fired on the main square where about 5000 people were demonstrating against President Karimov's government.
Soldiers fired in the air and at the crowd as they drove several times through the centre in a lorry.
The crowd fled in panic.
Half an hour after the first shots, more shooting could be heard and smoke was visible from the square. A helicopter flew overhead.
Night of terror
Witnesses described their terror as the violence broke out in the dead of Thursday night.
"The shooting started at 11.45 at night," a kindergarten teacher, who asked not to be named, said. "It was very close. I was afraid a bullet could hit my children. We didn't sleep at all and everyone's afraid."
It was one of the most serious crises to shake the energy-rich ex-Soviet republic, which is run by an authoritarian government and is host to a major US air base used for operations in Afghanistan.
Uzbek leader Islam Karimov (R)
is viewed by critics as autocratic
A Foreign Ministry spokesman in Tashkent, the capital, told AFP that security forces had brought the situation under control, but an AFP correspondent said the rebels still held the administration building.
After the night's fighting died down, thousands of demonstrators had gathered in the city centre, calling on Karimov to resign and protesting against the country's lack of democracy.
Earlier, Aljazeera's Akram Khuzam, reporting from Moscow, quoted the Uzbek Foreign Ministry as saying security forces were in control of Andijan and that they did not want to disperse demonstrators by force.
The fighters that stormed the prison on Thursday called for Karimov's resignation, appealing to Russia to mediate as well as prod the government to meet their demands, unofficial Uzbek sources told Aljazeera.
The protesters chanted slogans calling for democracy and better job opportunities for the thousands of unemployed people in Uzbekistan, the correspondent said.
Uzbek authorities' human rights
practices are under scrutiny
Russia's Interfax news agency reported that talks with the rebel fighters - initially reported to be between 60 and 100 - were starting.
The authorities blocked broadcasts of BBC and CNN television.
State television showed films and entertainment programmes. The country's border with Kyrgyzstan was shut.
The unrest in Andijan, which has a population of 300,000 and is the fourth largest city in Uzbekistan, started with protests against a trial of 23 men charged with forming a cell of the outlawed Islamic group Akromiya.
For days a crowd of about 2000 people had demonstrated in support of the men, saying they were victims of repression.
Russian Foreign Minister Sergei Lavrov appeared to rule out intervention, saying the disturbance was an internal affair of Uzbekistan.
"It was very close. I was afraid a bullet could hit my children. We didn't sleep at all and everyone's afraid"
Kindergarten teacher in Andijan
Meanwhile in Tashkent, the US embassy initially reported that a would-be bomber had been shot outside the Israeli embassy. However, Uzbek officials later said the man turned out to be unarmed.
Bombings at the US and Israeli embassies last year killed two people, and were claimed by a group calling itself the Islamic Movement of Uzbekistan.
Independent analysts say Karimov's autocratic government has used the fear of Islamist rebellion as a cover for the suppression of any opposition to his rule.
The Akromiya group, to which the men on trial in Andijan allegedly belong, is an offshoot of the better known Hizb ut-Tahrir, which seeks to create an Islamic state throughout the Central Asian former Soviet republics.
The protest in Andijan had been growing in size daily as the trial, started in February, approached its conclusion.
Most of the defendants are owners of small and medium-sized businesses and provide badly needed employment in the impoverished area.
Karimov is an imortant ally in Washington's "war on terror", having provided US forces with a major air base near the Afghan border since 2001.
Protests - long virtually unheard of in Uzbekistan - have become more common in the past year.