MIAMI — The military judge presiding over the Sept. 11 war crimes proceedings at Guantanamo Bay says he will lift his order prohibiting female guards from having physical contact with the five defendants at the U.S. base in Cuba, attorneys involved in the case said Friday.

But Army Col. James Pohl also said he would keep the ban in place for six more months. That is because of what he calls "inappropriate" public criticism of his order by Defense Secretary Ash Carter and Marine Corps Gen. Joseph Dunford, chairman of the joint chiefs of staff, during an October appearance before Congress.

Pohl said in his 39-page ruling that the "disparaging" comments by Carter and Dunford created the appearance that they were trying to influence the ongoing death penalty military commission for the five men accused of planning and aiding the Sept. 11, 2001, terrorist attack.

"These comments were entirely inappropriate," the judge said. "They crossed the line. Senior military leaders should know better than to make these kinds of comments in a public forum during an ongoing trial."

Carter called the ban on women having contact with the defendants an "outrage" and "counter to the way we treat service members" in testimony to the Senate Armed Services Committee.

The judge's ruling was issued Thursday but has not yet been released to the public. Defense attorneys disclosed its contents to The Associated Press. A Pentagon spokesman had no immediate comment.

Lawyers for the prisoners said that contact with women unrelated to them violates their strict Muslim beliefs. The judge acknowledged those beliefs in his ruling, but said the military had a superseding interest in being able to run gender-neutral guard operations and to ensure adequate staffing at the prison.

The ruling only applies to the defendants in the Sept. 11 case who are held in a top-secret section of Guantanamo known as Camp 7 and are moved throughout the prison by special escort teams.

Walter Ruiz, the lawyer for defendant Mustafa al-Hawsawi, said he was disappointed that the judge intends to reverse his earlier decision. He said some defendants will refuse to meet with their attorneys or attend court sessions to avoid contact with unrelated females. "This issue is not about women, this issue is about legitimate religious and cultural sensitivities," he said.

The five defendants face charges that include nearly 3,000 counts of murder in violation of the law of war and terrorism. Pretrial hearings are expected to resume next month.

Copyright 2016 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.