Army Pfc. Bradley Manning faces 22 charges, including espionage and aiding the enemy, and could receive a life sentence. (Patrick Semansky/AP)

A military judge refused Tuesday to toss out the case against WikiLeaks suspect Bradley Manning but ruled that any sentence the Army private receives should be reduced by 112 days because of his mistreatment in confinement.

Manning’s confinement at a military jail in Quantico, Va., was “more rigorous than necessary,” said Army Col. Denise Lind, the military judge presiding over the hearing at Fort Meade, Md. Maintaining him in suicide risk over mental health recommendations “became excessive in relation to legitimate government interests.”

Nonetheless, she said, “dismissal of charges is not appropriate” and would be fitting only in the case of “outrageous” conduct.

The prospects for Lind dismissing the case were considered slim. Manning, an Oklahoma native who lived briefly in Potomac, faces a court-martial in March on charges of leaking hundreds of thousands of sensitive government documents to the anti-secrecy Web site WikiLeaks.

He faces 22 charges, including espionage and aiding the enemy, and could receive a life sentence.

“If Private Manning hoped that the entire case would be dismissed because of the way he was treated at the Quantico Marine brig, he was seriously unrealistic,” said Eugene Fidell, a Yale University law professor and military justice expert.

The government conceded at a pretrial hearing last month that Manning had been improperly held on suicide watch for seven days and should receive seven days off any sentence.

In that sense, Lind’s ruling is “a small victory” for Manning and his defense team, said Michael J. Navarre, a military justice expert and former military lawyer. “They’ve at least shown that the government was mistreating Manning for some period of time” at Quantico.

Manning, an Army intelligence analyst who served in Iraq, was arrested in May 2010 and eventually transferred to Quantico in July 2010. He testified last November that he felt like he was in “a shark-attack environment” at Quantico and that the guards were out to show they were in charge. “Everything I did was wrong,” he said.

Manning was kept alone in a windowless 6-by-8-foot cell 23 hours a day and forced while on suicide watch to sleep in only a “suicide smock,” which military officials said is standard procedure when inmates are believed to pose a risk to their own safety. In March 2011, after eight months of confinement, Manning quipped sarcastically that he could kill himself with the elastic of his underwear if he wanted to.

Manning, 25, has acknowledged contemplating suicide shortly after his arrest but said that he tried to convince guards for month that he was not a threat to himself or anyone else.

At Quantico, he was monitored 24 hours a day, at times growing so bored and starved for companionship that he danced in his cell and played peekaboo with guards and with his image in the mirror — activity his defense attorney attributed to “being treated as a zoo animal.”

He was barred from exercising in his cell and slept on a mattress with a built-in pillow. He had no sheet, only a blanket designed so that it could not be shredded.

Forensic psychiatrists who saw Manning testified last month that there was no medical reason for him to be on suicide watch.

The conditions of his confinement were so controversial that they prompted Juan E. Mendez, the United Nations special rapporteur on torture, to seek to interview Manning directly and without monitoring, but his request was refused.

In December, the judge accepted terms that could allow Manning to plead guilty to some lesser charges. The private would accept responsibility for providing classified material to WikiLeaks in exchange for a maximum term of 16 years in prison.

Manning, who was 22 when he was arrested, is being held at Fort Leavenworth, Kan. He has spent 959 days in pretrial detention, and his defense team has argued that his right to a speedy trial has been violated.