WASHINGTON — The Supreme Court on Monday refused to hear a lawsuit by a Yemeni man who has been held in wartime detention for more than 17 years at the military’s Guantánamo Bay prison, prompting Justice Stephen G. Breyer to warn that the American legal system is on autopilot toward permitting life imprisonment without trial.

“It is past time to confront the difficult question left open by” a 2004 ruling allowing the indefinite detention of Guantánamo detainees captured after the 2001 American invasion of Afghanistan, Justice Breyer wrote in a statement about the denial of the request to hear the man’s appeal.

That difficult question: In a war that effectively has no end, is it lawful to hold a person in perpetual detention, until he dies of natural causes decades after his capture, because he was once part of an enemy force — though never charged with committing a crime?

Because fighting in Afghanistan against Al Qaeda and the Taliban continues with no end in sight, the roughly 42-year-old detainee who brought the case, who was captured there in 2001 and taken to the naval base in Cuba in January 2002, “faces the real prospect that he will spend the rest of his life in detention based on his status as an enemy combatant a generation ago,” Justice Breyer wrote.