LONDON — In the first book known to be published by a former Guantanamo Bay prisoner, Moazzam Begg says his three years in detention were marked by beatings, fear and unexpected friendships with his captors.

In “Enemy Combatant: A British Muslim’s Journey to Guantanamo and Back” Begg describes his upbringing as a British Muslim from Birmingham who studied at a Jewish academy and sang Christian hymns in high school.

“I understood why the Americans felt they needed to question me,” Begg, 37, told The Associated Press. “But I’ve never understood how they could have detained me for years.”

It isn’t difficult to see why Begg attracted suspicion.

He says he was working on an aid project building wells and schools in Afghanistan on Sept. 11, 2001. It was financed by Muslims in Birmingham.

Years earlier, he went to Bosnia to support Muslims in the war, and visited camps in Afghanistan where Muslims — some linked to the Taliban or al-Qaida — were trained to fight in Chechnya and Kashmir. He also visited a front line in Afghanistan, but says he never trained or fought there.

“Back home in Birmingham, I began to feel in all the confusion of speaking both English and Urdu. … the one thing that was coherent … was my religion,” he writes in the book, released in Britain on Monday.

Begg was freed last year after being held for three years without charges — two years at the U.S. prison camp in Guantanamo Bay, Cuba, and about a year at U.S. camps in Afghanistan. Some 490 men are still held in Guantanamo, some for years without charge.

The United States accused Begg of being a member of the al-Qaida terror network that planned the Sept. 11 attacks, as well as recruiting for al-Qaida, sending money and support to al-Qaida camps, attending training camps linked to the terror group and preparing to fight U.S. and allied forces.

He admits to supporting militant Muslims in Bosnia, Chechnya and Kashmir, but says he does not support suicide bombers or the Sept. 11 attacks. He even admits to buying a handgun in Afghanistan, but says he never received military training or planned to fight.

Despite his release, the U.S. government still views him with suspicion and has offered no apology for holding him or designating him an enemy combatant, a classification that provides fewer protections than prisoner of war status.

Begg said he was handed over to the U.S. military by Pakistani forces in January 2002 after fleeing U.S. bombing in Afghanistan with his family. From there, he was held in Kandahar and Bagram, where he said he was beaten and threatened. A Pentagon spokesman denied the allegation.

Begg also said he saw U.S. troops severely beating detainees.

In his book, he writes: “I heard a scuffle, and then some dull thuds behind cell three.” He said he later saw two American guards, one of whom he knew from Kandahar, “dragging a limp body past our cell to the medical room. I could see bruises on the detainee’s face.” Begg said he later was told the man had died.

He said he suffered abuse at Bagram. “Guards tied my hands behind my back, hog-tied me so that my hands were shackled to my legs, which were also shackled,” he writes. “A barrage of kicks to my head and back followed … I lost track of day or night.”

He also said a banner desecrating Islam hung at the detention center, where cells were named after previous terror attacks, such as the bombing of the USS Cole in Yemen.

Bryan Whitman, a Pentagon spokesman, said in a statement there was “no credible evidence that Begg was ever abused by U.S. forces.” However, he declined to answer specific questions or say whether Begg’s abuse allegations were investigated.

“He (Begg) certainly is a sympathizer, a recruiter, a financier and a combatant,” Whitman said in the statement. “He admitted, and this again is a quote from him, ‘I was armed and prepared to fight alongside the Taliban and al-Qaida against the U.S. and others and eventually retreated to Tora Bora to flee from U.S. forces when our front lines collapsed.'”

“So Begg’s story today is a whole lot different than what we know about Begg and what Begg has told us about Begg. Why is his story different? Well, his story is different because he is clearly lying. It shouldn’t surprise us that he’s lying. We know that terrorists are trained to lie,” the statement said.

Begg says his treatment improved at Guantanamo Bay, where he formed friendships with guards and interrogators.

But as he neared two years at the Caribbean outpost, he said he broke down and signed a confession written by his captors. Other detainees have also reported signing false confessions.

The government refused Monday to provide a copy to the AP.

“The people who showed up with this document were the same ones who ordered my beatings in Bagram and who told me I could be facing execution,” Begg said.

He said his first contact with Afghanistan came in 1993 when he visited his father’s family in Pakistan as “part of my own search for identity.”

Begg admits to supporting Muslims in Bosnia — a cause fueled by meeting Bosnian refugees who stayed at his father’s house — and visiting two training camps in Afghanistan — one for Kashmiris, the other for Kurds fighting Saddam Hussein.

“I was interested in the Taliban as a populist movement but my intention was to help Afghanis, not the Taliban,” he said.

Begg, who lives with his wife and four children in Birmingham, says he is proud to be British but it’s difficult for Muslims in a nation still reeling from last year’s deadly suicide bombings on the London transit system.

Not only was racial animus a likely factor when Charter Communications repeatedly rejected negotiations with Entertainment Studios, the TV programmer, but Charter's attempt to shield itself from allegations of bias using the First Amendment is also without merit, according to the U.S. Court of Appeals for the Ninth Circuit.