At least nine people were killed and dozens wounded, witnesses and officials said.
One protester, who put the death toll as high as 20, said 30 soldiers were being held hostage because they were shooting at demonstrators. Two of the dead were children, Sharif Shakirov, a brother of one of the defendants told The Associated Press.
President Islam Karimov and other top officials rushed to the eastern city of Andijan, where the government insisted it remained in control despite the chaos, though it blocked foreign news reports for its domestic audience.
Andijan is in the Fergana Valley, where Islamist sentiment is high, provoking tensions with the secular government that tolerates only officially approved Muslim observances.
The Islamic Movement of Uzbekistan, linked to al-Qaida and the Taliban, fought for establishment of an Islamic state in the valley in the late 1990s and concerns are high that Fergana could be a flashpoint for destabilizing wide swathes of ex-Soviet Central Asia.
The unrest prompted neighboring Kyrgyzstan and Kazakstan, which also share the valley, to seal their borders.
"The people have risen," said Valijon Atakhonjonov, a brother of another one of the defendants.
Karimov's office said nine people were killed and 34 wounded in clashes between protesters and security forces.
Protesters stormed the prison overnight, apparently after attacking a military unit to get weapons, officials and witnesses said. All 23 defendants --prominent businessmen accused of terror ties and Islamic extremism --were freed, said defendant Abduvosid Egomov, 33.
Egomov, pale and thin, was holed up in a local government compound that had been overrun by protesters, who were breaking up pavement stones to reinforce a metal fence surrounding the compound, to stave off security forces.
"We are not going to overthrow the government. We demand economic freedom," Egomov told The Associated Press.
"If the army is going to storm, if they're going to shoot, we are ready to die instead of living as we are living now. The Uzbek people have been reduced to living like dirt," Egomov said.
The trial, which has provoked some of the angriest demonstrations yet against the authoritarian government, is part of a broad government crackdownon religious dissent.
Thousands of Muslims have been jailed in Uzbekistan over the past few years in a government campaign that critics say has affected many innocent believers and only inflamed anger against Karimov's harsh rule.
Uzbeks in recent weeks have shown increasing willingness to challenge their leadership, apparently bolstered by the March uprising in Kyrgyzstan that drove out President Askar Akayev and by the so-called Orange and Rose Revolutions in Ukraine and Georgia.
Shakirov told the AP that the jailbreak was triggered by news that security services on Thursday had started rounding up people who had been involved in a sit-in outside the court where the trial was taking place.
On the square outside the local administration building, thousands of protesters were massed in front of a podium where protest organizers addressed the crowd. Some had Kalashnikov automatic rifles strapped across their chests.
Shakirov said that protesters on Friday had repulsed several attempts by the army to storm the regional administration building they have held in Andijan since shortly after midnight.
Many of the men wore square black embroidered skullcaps, while some were in the white skullcaps favored by observant Muslim Uzbeks. Young men handed out round flatbreads. The protesters had posted their own guards on the edge of the square.
A nearby theater and cinema were burning, and a group of protesters examined the remains of burned-out car.
In the capital, Tashkent, on Friday a suspected suicide bomber was shot and killed outside the Israeli Embassy on Friday morning, according to the U.S. Embassy, but it was unclear if the incident had any link to the unrest in Andijan.
Uzbekistan, a key U.S. ally after the Sept. 11 attacks, hosts hundreds of US troops.
The men, arrested in June, are accused of being members of the Akramia religious group and having contacts with the outlawed radical Islamic party Hizb-ut-Tahrir.
Authorities accuse Hizb-ut-Tahrir of inspiring terror attacks in Uzbekistan last year that killed more than 50. The group, which claims to eschew violence, denied responsibility.
Akramia unites followers of jailed Uzbek Islamic dissident Akram Yuldashev, who was accused of calling for the overthrow of the predominantly Muslim country's secular government -- an accusation he denies.
The group's members are considered the backbone of Andijan's small business community, giving employment to thousands of people in the impoverished and densely populated Fergana Valley.