MARIB, Yemen — Farouk Baakar's mistake was taking a selfie.
The Yemeni medic was on duty at al-Rashid hospital the day when a bleeding man was brought into the emergency room with gunshot wounds and signs of torture. He had been dumped on the side of a highway after being held in a prison run by the Houthi militiamen who control northern Yemen. He'd been whipped across the back and hung by his wrists for days.
Baakar spent hours removing bullets and repairing ruptured intestine. He tended to the patient's recovery for 80 days and, at the end, agreed to pose for a selfie with him.
Weeks later, Houthi security officials grabbed the man again. They searched his phone and found the photo.
Militiamen stormed the hospital in the port city of Hodeida, blindfolded Baakar and hustled him away in a pickup truck. Because he'd given medical help to an enemy of the Houthis, they told him, he was now their enemy too. After his arrest in mid-2016, he spent 18 months imprisoned. During that time, he says, they burned him, beat him and chained him to the ceiling by his wrists.
Baakar and his patient are among thousands imprisoned by Houthi rebels during Yemen's four-year civil war. Many of them, an Associated Press investigation found, suffered extreme torture — smashed in their faces with batons, hung by their wrists or genitals for weeks at a time or scorched with acid.
The AP spoke with 23 people who said they survived or witnessed torture in Houthi detention sites, as well as with eight relatives of detainees, five lawyers and rights activists, and three security officers involved in previous prisoner swaps who said they saw marks of torture on inmates.
These accounts underscore the significance of an agreement on a prisoner swap reached in Sweden on Thursday at the start of U.N.-sponsored peace talks between Yemen's Shiite Houthi rebels and the Yemeni government, backed by Saudi Arabia and the United States. As a trust-building measure, the two sides agreed to release several thousand prisoners, though details still must be hammered out.
But while the government would release captured Houthi fighters, the rebels would largely free civilians who, like Baakar, were imprisoned during sweeps aimed at suppressing opposition and obtaining captives who could be traded for ransom or exchanged for Houthi fighters held by the other side.
The Abductees' Mothers Union, an association of female relatives of detainees jailed by Houthis, has documented more than 18,000 detainees in the last four years, including 1,000 cases of torture in a network of secret prisons, according to Sabah Mohammed, a representative of the group in the city of Marib.
The mothers' group says at least 126 prisoners have died from torture since the Houthis took over the capital, Sanaa, in late 2014.
Amnesty International says that "horrific human rights abuses, as well as war crimes, are being committed throughout the country by all parties to the conflict."
But international outrage over the bloodshed in Yemen has largely focused on abuses carried out by the U.S.-backed and Saudi-led military coalition fighting on the side of the Yemeni government. The AP has exposed torture at secret prisons run by the United Arab Emirates and their Yemeni allies and has documented the deaths of civilians from strikes by drones in the United States' campaign against al-Qaida's branch in Yemen.
Abuses by the Houthis have been less visible to the outside world.
Houthi leaders previously have denied they engage in torture, though they did not respond to repeated AP requests for comment in recent weeks. The Houthis' Human Rights Ministry said in late 2016 that "there is no policy or systematic use of torture on prisoners."
But within the movement, a moderate faction has acknowledged abuses and sought to end them. Yahia al-Houthi, the brother of the group's top leader, set up a committee in 2016 to investigate reports of torture. It helped free 13,500 prisoners in its first three months.
The committee sent a video report to the leader, Abdel-Malek al-Houthi, showing scenes of overcrowded prison wards along with testimony from senior Houthis on the committee who said they saw signs of torture. The video was not made public, but the AP obtained a copy.
"What we saw would make you cry tears of blood," one committee member says in the video.
Abdel-Malek never responded to the video. Instead, hard-line security officials shut down the committee and briefly detained two of its members.
The video report echoes the accounts victims gave to the AP.
Baakar, the medic, said that after his arrest, the militiamen hung him from the ceiling, stripped him, whipped his naked body, then pulled out his nails and tore out his hair. He fainted. Once they brought plastic bottles and with a lighter melted the plastic over his head, back, and between his thighs.
Eventually, Baakar was taken to Hodeida castle, a 500-year-old Ottoman-era fortress. In a filthy basement known as the "Pressure Room," he was hung by his wrists for 50 days, until his captors thought he was dead. They cut him down, and when they realized he was still alive, allowed other prisoners to feed and clean him.
As he recovered, other tortured detainees asked for his help. He tried to treat their injuries, even carrying out simple surgeries, without anesthesia and using electric wires, the only tool he had.
Baakar, who was freed in December 2017 after his family paid the equivalent of $8,000, recalled helping a man who'd been hung by his penis and testes. Another man had been badly burned when the Houthis poured acid on his back, melting his skin and nearly sealing his buttocks. Baakar used wires to make an opening and, with his fingers, removed the stool.
"When I asked Houthi guards for help, saying the man is dying, their only answer was: 'Let him die.'"