WASHINGTON — In a reversal of an 18-year-old military policy that critics said was hiding the ultimate cost of the wars in Iraq and Afghanistan, the news media will now be allowed to photograph the flag-draped coffins of America's war dead as their bodies are returned to the United States, but only if the families of the dead agree.

The decision, which Defense Secretary Robert Gates announced Thursday, lifts a 1991 blanket ban on such photographs put in place under President George Bush. It chiefly affects coffins arriving from Iraq and Afghanistan that go through Dover Air Force Base in Delaware.

"I think that foremost in our thinking about issues like this should be the families and giving them choices," Gates said at a news conference at the Pentagon.

Renewed as recently as a year ago by the administration of President George W. Bush, the ban has long been a source of intense debate.