WASHINGTON — As United States troops prepare to exit Iraq at the end of the month, the Obama administration is facing a significant dilemma over what to do with the last remaining detainee held by the American military in Iraq.

The detainee, Ali Musa Daqduq, a Lebanese suspected of being a Hezbollah operative, is accused of helping to orchestrate a January 2007 raid by Shiite militants that resulted in the death of five American soldiers. The administration is wrestling with either turning him over to the Iraqi government — as the United States did with its other wartime prisoners — or seeking a way to take him with the military as it withdraws, according to interviews with officials familiar with the deliberations.

But each option for dealing with Mr. Daqduq has drawbacks, officials say, virtually guaranteeing that his fate will add a messy footnote to the end of the Iraq war. Mr. Daqduq is likely to be a subject of negotiation when Prime Minister Nuri Kamal al-Maliki of Iraq meets with President Obama at the White House on Monday.

“There are serious and ongoing deliberations about how to handle this individual to best protect U.S. service members and broader U.S. interests,” said Tommy Vietor, a spokesman for the National Security Council.