Longtime prisoners on hunger strike at the Guantánamo detention camp for terrorism suspects are asking a federal judge to order the US government to stop forcibly drugging them and to stop force-feeding them in advance of the religious fast during Ramadan.

The month-long fast, celebrated by all Muslims, is set to begin with the new moon on July 8.

The motion was filed Sunday. It asks the judge to block US officials from continuing to administer a drug said to cause dangerous side effects. Prolonged use of the drug, Reglan, may cause a neurological muscular disorder similar to Parkinson’s disease, lawyers for the detainees say. It can also trigger depression, suicidal thoughts, and suicide, they argue.

On Monday, US District Judge Rosemary Collyer gave the government two days, until July 3, to respond with its own motion.

The action was filed by lawyers with the London-based group Reprieve on behalf of four Guantánamo detainees.

“Being strapped to a chair and having a tube forcibly inserted through one’s nostrils and into one’s stomach is dishonorable and degrading. It falls within the ambit of torture or other forms of inhumane treatment,” the motion says in part.

“In the long history of American detention of the enemy, bodily invasions of this character have never been the routine business of the prisoner of war camp,” the motion says.

The motion adds that the forced administration of the drug Reglan in conjunction with the forced feeding violates the detainees’ right to refuse a drug “that poses a significant risk of adverse side effects from prolonged use.”

The practice is inhumane, violates human rights and medical ethics, and serves no legitimate penological interest, according to the motion.

The US military, which runs the detention camp, has defended the procedures used to feed the detainees, saying they are humane.

All four of the detainees have been cleared for release from Guantánamo, but the transfer process has been stopped because of a long-running stalemate between Congress and the White House.

They are among 166 detainees being held at the detention camp at the US Naval Base at Guantanamo Bay, Cuba. Eighty-six of the prisoners have been cleared for release. Lawyers estimate that 120 are currently on hunger strike and that, of those, 44 are being force-fed by US officials. The hunger strike began in early February to protest their indefinite detention without charge.

The four detainees who are the subject of the legal motion are Ahmed Belbacha and Nabil Hadjarab, both of Algeria, Shaker Aamer of Saudi Arabia, and Abu Wael Dhiab of Syria. All have been held at Guantánamo since 2002.

“After nearly a dozen years of limbo, the last thing my clients feel they have left is the basic dignity of choosing what goes into their bodies,” Cori Crider, a lawyer with Reprieve, said in a statement. “For the US military to strip this final right from them is appalling,” she said. “History will closely study how these men were treated.”

Jon Eisenberg, an Oakland, Calif., lawyer working with Reprieve on the case, added: “Force-feeding of prisoners is inhumane and a violation of medical ethics. When it is done for the purpose of keeping Guantanamo detainees alive so that they may continue to be held indefinitely without a trial of any sort, it is nothing short of grotesque.”

“President Obama has himself condemned the force-feeding, but he has not seen fit to stop it,” Mr. Eisenberg said in a statement. “His deeds have not matched his soaring rhetoric.”