MIAMI — The military judge presiding over the Sept. 11 war crimes proceedings at Guantánamo Bay has said in a ruling that he will eventually lift his order prohibiting female guards from having physical contact with the five defendants while transporting them around the American base in Cuba.

But the judge, Col. James Pohl of the Army, also said he would keep the ban in place for six more months, according to the order, which was disclosed to The Associated Press on Friday. That is because of what he termed “inappropriate” public criticism of his ban by Defense Secretary Ashton B. Carter and Gen. Joseph F. Dunford Jr., chairman of the Joint Chiefs of Staff, during an October appearance before Congress.

Colonel Pohl said in his 39-page ruling that the “disparaging” comments by Mr. Carter and General Dunford could be viewed as creating the appearance that they were trying to influence the death penalty military commission for the five men accused of planning and aiding the Sept. 11, 2001, terrorist attacks.

“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.”