(CNN) -- Just days after he escaped from Libya's infamous prison, Matthew VanDyke made an emotionally jarring return to the cramped cell he was held in solitary confinement for the past five months.
The aspiring adventure writer and freelance journalist walked through the now empty and ransacked Abu Salim prison, the site of a chaotic jail break led by rebel fighters who freed hundreds of political detainees.
Emotionally drained and physically frail, the 32-year-old Baltimore native looked at the tiny cell he had rarely been out of, and remembered the three steps he would take back and forth until he was too exhausted to stay awake.
While he heard fellow prisoners scream during torture, and some told CNN of beatings with electric wires, VanDyke says he was never physically abused.
"To be honest, I would have rather been occasionally beaten than put through this solitary," he said. "For all I knew, I was going to be here for the rest of my life."
Staring at the dirty white walls for weeks on end, he had no books, exercise and only occasional contact with fellow prisoners shouted down the cramped and dark hallways.
"In the beginning I considered suicide," he said.
The return to the prison marked the latest twist to VanDyke's story.
The freelance journalist and aspiring travel writer had not been heard from since mid-March, shortly before he was arrested in the city of al-Brega by forces loyal to Moammar Gadhafi.
He had been without contact with any family member, government official or aid organization since March 12, when he last spoke to his mother.
Having traveled to nearly a dozen Middle Eastern and African countries since 2007, VanDyke left for Benghazi in late February. Friends there had told him what was happening in Libya during the early stages of the revolution.
"He had a great respect for the people and the country, not the politics," his mother, Sharon VanDyke said.
VanDyke remembers being on a motorcycle trip to the eastern town of al-Brega with friends in March.
Although he had a U.S. passport and press credentials, he says he was seized by Gadhafi forces who suddenly appeared, hitting him and knocking him unconscious.
He remembers being confined in two prisons, including Abu Salim, from which he and the hundreds of others escaped Wednesday, one day after rebels seized Gadhafi's compound in the city.
Libyan officials had only recently acknowledged VanDyke was in custody.
After months of psychological torment by guards loyal to Gadhafi, when a commotion arose outside the door of his solitary confinement cell in Tripoli's most notorious prison, VanDyke was sure he was going to be executed.
VanDyke has described a harrowing 30 hours that took him from Abu Salim prison to the safe house under the protection of anti-Gadhafi rebels.
Early Wednesday, he said, he heard prisoners yelling, shouting and banging, not unlike the sounds he had heard as guards rousted out other prisoners during his six months of confinement.
As he stared at the white walls where he had ticked off the days until he lost track, he thought, "This is it, they've come to lynch me."
A hand opened the small slit in the door where his food was passed through. He heard someone angrily shouting and pointing at verses in an open Quran pushed through the door.
Not long after, someone hammered off the lock on the door.
At first he thought it was a trap, maybe a ruse to lure him in greater danger. But then the realization dawned: the guards had fled, and he had a chance to escape.
"It was relief, but it was also disbelief," he said Friday. "Because I still thought Gadhafi's guys would come back."
VanDyke had no possessions to gather up, only a wet and ragged prison uniform. He found a pair of sandals left behind by another fleeing prisoner and then escaped the prison along with hundreds of other inmates.
Many of those held in the facility were political prisoners, or had been caught up in crackdowns on rebel sympathizers or on the many battlefields edging closer to the capital.
VanDyke joined up with one small group walking through the Abu Salim neighborhood of Tripoli, not knowing that they were in one of the last areas still controlled by Gadhafi loyalists. They could hear explosions and gunfire, but also got news that rebels were taking control of the city.
The group made their way to a mosque. There, the imam and other neighborhood leaders were handing out cash, trying to help people desperately short of supplies amid the chaos and electrical blackout in the area.
VanDyke said he moved on, to a makeshift hospital where he got some help and directions to a local resident who had access to a working phone.
It was there he was able to make his first phone call back to his worried girlfriend, Lauren Fischer, and mother back in Baltimore.
VanDyke said he was eventually able to hook up with another escaped inmate who had ties to rebel forces and could speak English. The man gained access to a car and two guards armed with AK-47 assault rifles, and they sped through the night past rebel checkpoints.
Eventually he arrived at a house once occupied by an American expatriate couple who had hastily fled in the earliest days of the conflict.
VanDyke said the home had food on the counters, remnants from the last-second escape of the last people there, a welcome windfall for him after months of rancid prison food.
And the working phone that connected him to the outside world.
"I've always known he was OK," Sharon VanDyke said.