Updated

After a tense three-week stand-off between armed prisoners and Venezuelan troops, the last of more than 1,600 inmates filed out and agreed to be moved to other prisons.

Groups of inmates emerged from La Planta prison with their hands on their heads, flanked by National Guard soldiers, and stepped aboard trucks that carried them to other prisons. The authorities had been trying to persuade a group of armed inmates to give up and leave so that the crowded, decades-old prison could be permanently shut down.

While some prisoners had resisted those orders, the penitentiary turned into a focal point for debate about Venezuela's severe prison problems while heavy gunfire periodically erupted at the prison in recent weeks. The prisoners began coming out on Thursday night hours after volleys of gunfire broke out at the prison during clashes that left clouds of tear gas wafting through the Caracas neighborhood.

Iris Varela, the government's prisons minister, announced on Friday night that the last of the inmates had turned themselves over after negotiations with officials.

"There's no impossible mission," she said on television. "It came out better than expected and we've been able to close this facility."

More On This...

She said 1,693 inmates had come out in all since Thursday.

In a symbolic finish, officials took down a metal plaque at the prison, which was built in 1964. Varela called the prison's closing a gift to the surrounding neighborhood and said the community could have a say in deciding what will become of the prison compound in the future.

It came out better than expected and we've been able to close this facility.

— Iris Varela, Venezuela's prisons minister

Varela said the gunfire on Thursday resulted from a confrontation between inmates. Some prisoners, however, have accused National Guard troops of involvement. Video posted on the Internet showed bullets hitting the prison from the outside.

Varela said she would hold off to check official figures before providing a tally of how many people were hurt. National Assembly President Diosdado Cabello said hours earlier that at least three people in areas outside the prison were wounded by stray bullets during the frenzy of shooting on Thursday. Skirmishes also erupted outside the prison between distraught relatives of inmates and troops using tear gas to drive them away.

Once the inmates began to come out, though, the situation grew calm on the streets outside, where relatives of some prisoners have been camping out in recent days waiting for news. Varela said officials would go inside to inspect the empty prison on Saturday.

Venezuelan officials had announced plans to close La Planta following two escape attempts and complaints of overcrowding, saying the facility doesn't meet standards. But even after hundreds of inmates were moved to other prisons in recent weeks, a group of armed inmates effectively kept the authorities out of the prison since late last month.

Prison unrest and crowding have become major problems for President Hugo Chávez's government. Violence is common inside Venezuela's prisons, where inmates often manage to obtain weapons and drugs with the help of corrupt guards. The watchdog group Venezuelan Prisons Observatory says about 560 people died in Venezuelan prisons last year, up from 476 in 2010.

The group also said that La Planta was especially crowded. Although it was built for 350 prisoners, it recently had held about 2,600.

Tensions at La Planta prison had risen since April 27, when Varela said authorities found a tunnel dug by inmates that led to a sewer, foiling an escape attempt. Three days later, gunfire erupted at the prison after what Varela described as another escape attempt.

On May 8, heavy gunfire rang out at the prison and one man in a nearby apartment was killed by a stray bullet.

"This is truly a place where no human being can be under any conditions," Varela said on television outside La Planta while prisoners were streaming out. She noted that before the recent escape attempts one young woman was killed last month during a visit and that the authorities subsequently halted visits by inmates' relatives.

She said many prisoners were moved to El Rodeo I prison east of Caracas. That prison was the scene of clashes and a 27-day standoff last year pitting armed inmates against troops. Officials say the prison has been partially rebuilt after some areas were destroyed by fire during the violence and walls were knocked down by authorities searching for hidden weapons and other contraband.

In a phone call broadcast on state television, Chávez congratulated Varela on dealing with the situation at La Planta prison and reiterated promises to improve the country's prison system.

Based on reporting by The Associated Press.

Follow us on twitter.com/foxnewslatino
Like us at facebook.com/foxnewslatino