Bradley Manning, the Army private accused of leaking hundreds of thousands of classified documents to WikiLeaks, told a military judge on Thursday that he contemplated suicide soon after he was arrested in 2010 and that he was kept in isolation for 23 hours a day.

Speaking in a steady voice and wearing his dress uniform and rimless eyeglasses, Manning, 24, described the conditions of his imprisonment in Kuwait and later in a Marine Corps brig at Quantico, Va., as brutal and unrelenting.

At Quantico, he said, he was isolated in a 6-by-8-foot cell, monitored constantly by guards and awakened periodically during the night. He called the intake process when he first arrived at Quantico “a shark-attack environment.”

“They are showing you they are the ones in charge,” he said of the guards. “Everything I did was wrong.”

Manning’s remarks at a military court at Fort Meade marked the first time he has spoken in public since his arrest in May 2010 in Iraq.

He is accused of releasing 250,000 U.S. diplomatic cables and 500,000 Army reports to the anti-secrecy group WikiLeaks. U.S. authorities have said some of the material exposed intelligence sources and embarrassed foreign governments. He faces 22 charges, including espionage and aiding the enemy.

The conditions of his confinement are the focus of pretrial hearings in which his attorney, David Coombs, has argued that Manning was subject to “unlawful pretrial conditions.” Coombs has called the measures punitive and filed a motion asking the judge to dismiss the charges or reduce any sentence that is rendered.

Manning’s treatment has been condemned by legal experts and questioned by a United Nations human rights official.

Shortly before Manning took the stand Thursday, the judge accepted terms that could allow him to plead guilty to the lesser charges. Manning would accept responsibility for providing classified material to WikiLeaks in exchange for a maximum term of 16 years in prison.

For all the drama of Manning’s anticipated testimony, he appeared calm and composed as he recounted contemplating suicide after his arrest and described the conditions of his incarceration.

After his arrest in Baghdad, where he was an Army intelligence analyst, Manning said he was transferred to Kuwait and kept in virtual isolation. He said he became distraught and thought about suicide.

“I certainly contemplated it,” he testified. “Even if I made a noose, there was nothing I could do with it. It all felt pointless.”

He was placed on suicide watch and notified that he would be transferred to the United States in July 2010. Manning said he feared that he was going to the prison at Guantanamo Bay and was relieved when he learned he was flying to Baltimore-Washington International Marshall Airport.

“It was great to be in familiar surroundings, on American soil, at BWI,” he said.

But his elation turned sour when he arrived at the Marine Corps brig at Quantico, where he said the environment was hostile. When asked during intake about the suicide watch in Kuwait, he wrote, “Always planning, never acting.”

The military has said that Manning was kept in isolation because he is regarded as a maximum-security prisoner and that he was regarded as someone who was a danger to himself and other prisoners.

At one point in spring 2011, Manning testified that he told his guards he could kill himself with his underwear if he wanted to do so. He said he was forced to sleep naked under a suicide smock for nearly two months after the incident. On one occasion, he said, he was forced to stand naked in front of his cell during morning attendance.

Manning said he had no natural light in his cell and that he was awakened two or three times a night when he was on suicide watch. Coombs had him demonstrate the size of his cell by walking him through a replica in the courtroom. Manning also removed his Army jacket to put on the “suicide smock” in which he was forced to sleep.

Military officials have said concerns for his safety were warranted partly because Manning behaved erratically, including dancing and using a mirror to play peekaboo with guards.

Manning, who said he tried for months to convince guards that he was not a threat to himself or anyone else, testified that the dancing was a form of exercise and that the games with the mirror were a way to relieve the boredom of 23 hours a day in isolation.

“Most entertaining thing I had was the mirror,” he said. “I spent a lot of time at the mirror. Bored, sheer, out-of-my-mind boredom.”

Manning is expected to be cross-examined Friday by the prosecution. The case is scheduled to last through the weekend.

Ellen Nakashima contributed to this report.