Four gunmen who seized 52 hostages inside a Venezuelan bank have given themselves up on a roadside after being chased.
One of the gunmen accidentally shot himself in the leg when his weapon went off during the chase, but none of the hostages was seriously hurt, said Justice Minister Ramon Rodriguez Chacin, calling it a "100 percent" success.
"This nightmare is over," Guarico state Governor Eduardo Manuitt told state television.
The gunmen were captured less than two hours after they fled the bank in an ambulance with five of their hostages under a deal negotiated with police in Altagracia de Orituco.
Once the men pulled over, they first let three hostages go and then negotiated with police while holding on to the last two. They soon put down their guns and a grenade, and were ordered to the ground and arrested, Mr Manuitt said.
Their capture ended an ordeal that began on Monday morning with a botched bank robbery in the town, which is southeast of Caracas.
The hostage standoff at the Banco Provincial branch was the longest in at least a decade in Venezuela.
In the final hours, some hostages inside the bank held up signs in the windows with desperate pleas for help and used mobile phones to call their relatives.
Under the deal with police, the gunmen were permitted to leave with five hostages who agreed to accompany them, freeing the rest at the bank.
Police allowed the gunmen to flee because "they threatened to start killing the hostages in 20 minutes", Mr Manuitt said.
One of the hostages who later left with the gunmen, Vanessa Saavedra, spoke quietly and haltingly to Colombia's Caracol Radio by mobile phone from inside the bank, saying: "We don't want them to shoot ... We don't want them to open fire. Please."
Ms Saavedra's mother, Jasmin Gonzalez, said her daughter - a 25-year-old teller - volunteered to leave with the gunmen.
"She's very brave. I know she's going to come out of this fine," Ms Gonzalez said through tears outside the bank.
A total of 52 people were taken hostage at the bank on Monday, including five who were released during the standoff and two who managed to escape, Mr Rodriguez said. After another five left in the ambulance, 40 were left behind and freed, he said.
Other officials had earlier given lower estimates of about 30 hostages inside the bank.
Relatives and onlookers gathered at the front door while the hostages were led to waiting ambulances.
Those freed included a two-week-old baby, at least three other children under the age of 10, and a woman who is eight months pregnant. She was wheeled out on a stretcher.
One man emerged with a bandaged hand, carrying a girl in his arms.
The four gunmen entered the bank on Monday morning when a uniformed police officer pulled up to use the cash machine and surprised the would-be robbers, said Amanda Saldivia, a reporter for the local Guarana Radio FM.
"After five or six hours, they began to let down their guard saying, 'You aren't going to die'," freed hostage Juan Carlos Gil said of his captors. "They were nervous, but it was all an atmosphere as if they were everyone's friends."
His account differed from that of the justice minister, who said the gunmen had been taking drugs, making the situation volatile.
Mr Gil said he never saw any of the gunmen use drugs and they appeared sober.
But Ms Saavedra said she was terrified when the men pointed a gun at a security guard and threatened him. "He went out running and they shot at him" but missed, Ms Saavedra told Caracol. "It was truly horrific."
Every twist and turn of the hostage drama became a spectacle in TV and radio news reports in Venezuela - and in neighbouring Colombia.
The radio station Caracol even contacted the gunmen, one of whom said: "I haven't eaten anything. ... I've kept myself going on sugar."
Mr Rodriguez celebrated what he called impeccable work by police and lashed out at what he called the "yellow journalism" of some Venezuelan and Colombian media, saying they tried to use "images of terror" to create panic in the population.
Shortly before the kidnappers fled the bank, one of the hostages broke a window in desperation, and one of the gunmen fired a shot in response, Mr Manuitt said.
Officials did not say if the gunmen left with any money.
Police officers with assault rifles took up positions at windows directly above the bank during the standoff, and then stood down at the urging of a hostage as the ambulance pulled up to ferry the group away.
Security cameras captured images of the gunmen until the cameras went dead - apparently cut off by the men - and the footage was turned over to authorities, said Leon Enrique Cottin, the Venezuela president of Spain's Bilbao Vizcaya Argentaria, or BBVA, which owns Banco Provincial.
As for the gunmen, Mr Manuitt told state television, "We think they don't have much experience because of the sort of weapons they carry and by their behaviour."
He said they carried handguns and "a type of grenade".Reuse content