WASHINGTON — The Trump White House is nearing completion of an order that would direct the Pentagon to bring future Islamic State detainees to the Guantánamo Bay prison, despite warnings from national security officials and legal scholars that doing so risks undermining the effort to combat the group, according to administration officials and a draft executive order obtained by The New York Times.

White House officials have detailed their thinking about a new detainee policy in an evolving series of drafts of an executive order being circulated among national security officials for comment. While previous versions have shown that the draft has undergone many changes — including dropping language about reviving C.I.A. prisons — the plan to add Islamic State detainees to the Guantánamo population has remained constant.

The latest version of the draft, which circulated this week, would direct Defense Secretary Jim Mattis to use Guantánamo to detain suspected members of “Al Qaeda, the Taliban, and associated forces, including individuals and networks associated with the Islamic State.”

The White House has kept similar language in the draft order despite warnings from career government national security officials that carrying out its plan would give federal judges an opportunity to reject the executive branch’s theory that the war against the Islamic State is legal, even though Congress never explicitly authorized it. The issue could arise when reviewing an inevitable habeas corpus lawsuit filed by an ISIS detainee.