The Obama administration wants to continue conducting searches of the genital areas of detainees at Guantanamo Bay, Cuba, deeming them essential to the security of the facility, so Wednesday it appealed a ruling of a federal judge who called the practice “religiously and culturally abhorrent.”

U.S. District Court Judge Royce C. Lamberth last week ordered guards at Guantanamo Bay to stop using their hands to conduct groin searches and to revert to an earlier method of shaking detainees’ pants to dislodge any contraband.

But in a declaration to the appeals court seeking a stay of Lamberth’s ruling, Marine Gen. John F. Kelly, who leads the U.S. Southern Command, essentially rebuked the chief judge and said he considers “prohibiting the search of the areas between detainees’ waists and knees” an “unacceptable risk to the military personnel under my command.”

The appeals court granted the stay Wednesday.

The government argued that for the first time to its knowledge, “a federal court has restricted a military commander from implementing routine security measures at a detention facility holding enemy forces.”

In a long, detailed submission to the court, Kelly also expressed his displeasure that Lamberth’s ruling included “significant and substantive information” on search procedures at the military detention facility, which houses 166 detainees. Kelly noted that the material was submitted “under seal and designated as protected” but that the military will have to review its procedures because “the general public and the detainee population now know the specifics.”

Attorneys for detainees had argued that the searches, which were introduced in May, were designed to impede meetings between inmates and their lawyers. At the time, there was a growing hunger strike by the prisoners, which began in February over searches of the detainees’ Korans and had expanded into a protest of the Obama administration not closing the facility.

Lamberth described the government as “recidivist when it comes to denying counsel access” at Guantanamo Bay.

Attorneys for detainees said they were dismayed by the government’s decision to obtain a stay and appeal the ruling.

“Does the military really think there’ll be an outbreak of smuggling if it can’t grope the men while it appeals the decision?” said David Remes, an attorney for several detainees. “The military can prevent smuggling without groping the detainees. This is really about who calls the shots — the court or the military — when it comes to protecting the detainees’ access to counsel.”

But in his declaration, Kelly said the military fully supports attorneys’ access to their clients, and he noted that in the first six months of the year, Joint Task Force-Guantanamo helped organize 193 face-to-face meetings and 100 phone calls.

Kelly said Army Col. John V. Bogdan, the commander of the detention group at Guantanamo Bay, had instituted new search procedures after the suicide of Adnan Latif, a detainee from Yemen, and the discovery of contraband, including improvised weapons such as shanks at the facility.

Kelly said “more fulsome searches” are used only when detainees are moved outside the camps where they are held “because the majority of the contraband seems to be coming from outside the camps.” Apart from their attorneys, the only non-military personnel the detainees can meet are officials from the International Committee of the Red Cross.