The psychiatrist who treated the WikiLeaks suspect, Bradley Manning, while he was in custody in the brig at Quantico has testified that his medical advice was regularly ignored by marine commanders who continued to impose harsh conditions on the soldier even though he posed no risk of suicide.

Captain William Hoctor told Manning's pre-trial hearing at Fort Meade that he grew frustrated and angry at the persistent refusal by marine officers to take on board his medical recommendations. The forensic psychiatrist said that he had never experienced such an unreceptive response from his military colleagues, not even when he treated terrorist suspects held at Guantanamo.

"I had been a senior medical officer for 24 years at the time, and I had never experienced anything like this. It was clear to me they had made up their mind on a certain cause of action, and my recommendations had no impact," Hoctor said.

The psychiatrist was testifying at Manning's court martial for allegedly being the source of the massive leak of hundreds of thousands of confidential US government documents to the whistleblower website WikiLeaks. The 24-year-old soldier, who worked as an intelligence analyst until his arrest in Iraq in May 2010, faces 22 counts and possible life in military custody.

Manning's defence lawyers are attempting to have the charges thrown out or any eventual sentence reduced by seeking to prove that the soldier was subjected to unlawful pre-trial punishment at Quantico. During the nine months he was in custody at the marine base in Virginia he was put on suicide watch and a "prevention of injury" order, or PoI, that kept him in solitary confinement and exposed him to extreme conditions that were denounced by the UN and Amnesty International as a form of torture.

Hoctor began treating Manning from the day after he arrived at Quantico on 29 July 2010, seeing him initially every day and then later once a week. At first he recommended that the soldier be put on suicide watch - the most stringent form of custody - given that he had mentioned killing himself while previously held in Kuwait and that nooses that he had made were found in his cell.

But within a week of seeing Manning he changed his recommendation, reporting to officers that in his medical opinion the soldier could be put on the lesser PoI status. His advice was ignored for a couple of weeks, Hoctor told the court. "At Quantico they often did not immediately follow, or sometimes did not follow at all, my recommendations."

The failure to act on the doctor's recommendation was an apparent violation of the instructions under which marine installations operate. The regulations state that "when prisoners are no longer considered to be suicide risks by a medical officer, they shall be returned to appropriate quarters."

By 27 August 2010, Hoctor testified, he had spent enough time with Manning to recommend a further easing of conditions. From then on he advised in a regular weekly report that Manning should be taken off PoI altogether and returned to the general brig population.

"I was satisfied he no longer presented a risk. He did not appear to be persistently depressed, he was not reporting suicidal thoughts, in general he was well behaved."

Specifically, Hoctor was convinced that Manning no longer needed to be subjected to restrictive conditions that included: no contact with other people, being kept in his cell for more than 23 hours a day, being checked every five minutes, sleeping on a suicide mattress with no bedding, having his prescription glasses taken away, lights kept on at night, having toilet paper removed.

Only on two occasions did Hoctor report that Manning appeared upset and should be put temporarily under close observation. The first incident occurred in December 2010 when Fox News erroneously reported that Manning had died, and the second in January 2011 when the soldier broke down in tears while in the exercise room.

Yet the psychiatrist's recommendation that other than these isolated incidents Manning should be treated like other inmates was consistently ignored. The soldier was kept on PoI throughout the rest of his time at Quantico.

The blanket denial of his expert opinion was unprecedented in his quarter century of practice, the psychiatrist said. "Even when I did tours in Guantanamo and cared for detainees there my recommendations on suicidal behaviour were followed."

Hoctor said he openly protested about the thwarting of his expert opinion at a meeting with the commander responsible for the brig, Colonel Robert Oltman, on 13 January 2011. At the meeting Oltman informed the doctor that Manning would be kept on PoI "for the forseeable future".

Hoctor said that the marine commanders should no longer pretend they were acting out of medical concern for the detainee. "It wasn't good for Manning. I really didn't like them using a psychiatric standard when I thought it clinically inappropriate," Hoctor said.

The court heard that Oltman replied: "You make your recommendations, and we'll do what we want to do."

Earlier the court martial heard from Oltman himself, who told the judge presiding over the proceedings, Colonel Denise Lind, that he had chosen to overlook Hoctor's advice because he didn't fully trust the doctor. A few months before Manning arrived at Quantico, an inmate of the brig, Captain Michael Webb, had killed himself while under Hoctor's care.

"I did not have the utmost confidence in Captain Hoctor," Oltman testified.

When that lack of trust was put to Hoctor by Manning's defence lawyer, David Coombs, the psychiatrist replied: "If they felt that way they should have got another person to do the job."

Despite the unprecedented conditions that Manning was held under, Hoctor said the detainee coped quite well. "Most people would have found it very difficult, being watched every five minutes, but he did better than expected – I think he decided he was going to be strong."