PJ Crowley, the official spokesman at the state department, has fallen on his sword after calling the treatment of Bradley Manning, the alleged source of the WikiLeaks files, "counterproductive and stupid".

The resignation followed Crowley's remarks to an MIT seminar last week about Manning's treatment in military prison.

Crowley had said: "What is being done to Bradley Manning is ridiculous and counterproductive and stupid on the part of the department of defence."

The remarks forced President Obama to address for the first time the issue of Manning's handling at Quantico marine base in Virginia. Obama defended the way Manning is being treated, saying he had been reassured by the Pentagon that his confinement was appropriate.

In a resignation letter, Crowley said he took full responsibility for his remarks. Though he attacked the leaking of classified information, which he called "a serious crime under US law", he stood by his earlier criticism of the Pentagon.

In words that could cause further difficulty for Obama, Crowley said his comments "were intended to highlight the broader, even strategic impact of discreet actions undertaken by national security agencies every day and their impact on our global standing and leadership. The exercise of power in today's challenging times and relentless media environment must be prudent and consistent with our laws and values."

When Obama entered the White House, he made improving the global standing of the US one of the key aims of his administration. He also denounced the extreme treatment of detainees by George W Bush as running counter to the national interest.

In her letter, Hilary Clinton said that "with regret" she had accepted Crowley's departure. "PJ has served our nation with distinction for more than three decades, in uniform and as a civilian," she said.

The resignation means that the furore over Manning has reached inner circles of the Obama administration. Manning has been held in solitary confinement for the past 10 months. He is being subjected to a prevention of injury order, which sees him kept in his cell for 23 hours a day and stripped naked at night.

The maximum security regime he is under in Quantico has been denounced by many, including Daniel Ellsberg, who leaked the Pentagon Papers on the Vietnam war, as a form of torture. The UN is also investigating.

Commentators have pointed out the apparent double standards behind Crowley's departure. Glenn Greenwald, a Salon reporter who has been outspoken about Manning's detention, tweeted that "detainee abuse is allowed, speaking out against it isn't".

Last week, Manning gave his own account of how he is being held, saying that it was harsh treatment designed to punish him even before he was put on trial. He said he was stripped naked every night after he made a sarcastic comment to guards about the absurdity of the regime he was under.

Manning has been charged with multiple counts relating to the leaking of thousands of secret US embassy cables, as well as videos and warlogs from Afghanistan and Iraq. He was arrested last May at a US military base outside Baghdad, where he had been working as an intelligence specialist.