(CNN) -- Among the places that Sen. John McCain, a prisoner of war in Vietnam, visited during his visit to Tripoli this week was Jdeida prison. McCain said he wanted to see detention facilities firsthand.
A fair system of justice -- absent for decades under strongman Moammar Gadhafi -- is an important step toward building a new Libya, the nation's Western allies have said.
McCain found overcrowding and a backed-up judicial system. Still, he said he found it encouraging that Libya's new leadership had allowed him and three fellow Republican lawmakers inside the Jdeida.
As of September 27, the two wings of Jdeida prison were housing about 1,500 detainees, according to Human Rights Watch, which over a one-month span inspected eight prisons in Tripoli and 12 smaller detention facilities.
The group spoke with 53 detainees to compile a picture of what happens when a nation goes to war with itself; when Libyans fight Libyans and the thirst for vengeance runs deep in the veins of people who have suffered for so long.
After Tripoli fell in August, militias took over providing security in the Libyan capital. But without strong central authority, the armed fighters have been able to act on their own accord. Thousand of people have been arrested without proper legal review, Human Rights Watch said.
These militias and other security groups aligned with the National Transitional Council have punished those suspected of murder and rape so severely that some of their actions could amount to torture, the rights group said in a report published this week.
Those interviewed told Human Rights Watch that they were beaten and given electric shocks. Some showed their scars as proof of their claims. One man wept openly in telling his story of abuse.
A detainee identified as Ahmed said this:
"They took an electric cable and started hitting me with it. They didn't use electricity, but they said that if I didn't talk, they would...They hit me with a butt of the Kalashnikov. They kicked me in the face and in the chest. One scratched me with the knife (bayonet) of the Kalashnikov."
Human Rights Watch said none of the detainees have ever faced a judge.
"After all that Libyans suffered in Moammar Gadhafi's jails, it's disheartening that some of the new authorities are subjecting detainees to arbitrary arrest and beatings today," said Joe Stork, deputy Middle East and North Africa director at Human Rights Watch.
"The NTC owes it to the people of Libya to show that they will institute the rule of law from the start,' Stork said.
An element of race was also disturbing.
Many of those arrested were dark-skinned Libyans and sub-Saharan Africans accused of having fought for Gadhafi, who had been known to make use of such mercenaries.
Abdulatif, a dark-complected Libyan, offered this account to Human Rights Watch:
"The rebels were taking turns. There were too many to count. Every day, there was a new face. They zapped me with an electric stick on my legs and on my arms. They did that twice. They asked me questions when they did this.... They asked me again and hit me. I said 'No, I swear I didn't,' so they started electrocuting me. They wanted me to confess but in the wrong way. They hit me every day. They used falaga (beating on the bottom of the feet]) and hit me on my back, all over my body, and slapped my face. They did this three times."
Mahmoud Jabril, Libya's de facto prime minister, recognized the problem and said it needed urgent attention.
"Prisoner abuse of any kind is not acceptable," he told Human Rights Watch. "We joined the revolution to end such mistreatment, not to see it continue in any form."
The global rights monitoring organization urged Libya's leaders to bring militia and security units under unified control and set clear standards for conduct.