WASHINGTON — A federal judge ruled on Monday that she had no power to order the military to refrain from force-feeding a detainee at the prison at Guantánamo Bay, Cuba. But in an unusual move, the judge made a direct appeal to President Obama to address issues raised by the hunger strike at the prison that has lasted months.

In a four-page ruling, Judge Gladys Kessler of the Federal District Court for the District of Columbia, rejected a request by the detainee, Jihad Ahmed Mujstafa Diyab, a 41-year-old Syrian man, to issue an injunction barring the military from forcing him to eat through a gastric tube inserted in his nose after restraining him in a chair.

Judge Kessler noted that the force-feeding of detainees had been condemned as a violation of medical ethics and human rights by groups as varied as the American Medical Association and top United Nations officials. And while the Obama administration defended its treatment of detainees as compassionate, she wrote, “it is perfectly clear” that “force-feeding is a painful, humiliating and degrading process.”

Nevertheless, Judge Kessler said she could not issue an injunction because Congress had barred the courts from intervening on issues involving conditions at the prison. But Mr. Obama, she wrote, “does have the authority to address the issue,” and she cited a speech in May in which he appeared to lament force-feedings. She noted that as commander in chief, Mr. Obama would seem to have the power “to directly address the issue of force-feeding of the detainees at Guantánamo Bay.”