The CIA and the Pentagon pulled out all the stops for the creators of "Zero Dark Thirty," staging interviews with officials and a Navy SEAL for an inside account of the hunt for Osama bin Laden.
Critics praised the movie's gritty and gripping feel but, with the film due for release in major European markets this week, controversy has erupted over claims that it justifies US agents' use of torture on detainees.
The access granted to director Kathryn Bigelow and screenwriter Mark Boal has turned the Oscar-nominated movie into the most detailed public account that exists of the May 2011 raid on a Pakistani compound to kill Bin Laden.
Nate Jones of the National Security Archives research institute dubbed it "the closest thing to the official story behind the pursuit of bin Laden."
Bigelow has been forced to release a statement denying widespread allegations that the film set out to justify or sanitize the "enhanced interrogation techniques" employed during the so-called 'war on terror'.
Although the assistance offered to the "Zero Dark Thirty" crew sparked accusations that the White House used the movie as a propaganda tool, cooperation between Hollywood and the Pentagon or CIA is nothing new.
The first film ever to win Best Picture at the Academy Awards, "Wings" in 1929, featured dogfight scenes with bi-planes thanks to help from the army.
It was the beginning of a relationship that has grown over decades.
The film industry covets access to hardware and expertise that only the armed forces can provide, while in return, defense officials want to burnish the military's image on the big screen.
The Pentagon's criteria for justifying cooperation on any film or television project is loosely defined, but until recently has never been seriously questioned by Congress.
"It just basically says: 'Is it something that might be of benefit for recruiting and retention? And/or is it something that might tell the American public more about the US military?" explained Philip Strub, who leads the Pentagon's liaison unit with the entertainment industry.
For the Pentagon, the decision whether to work on a film project all comes down to the script.
Characters in uniform need to reflect what officials consider to be an accurate picture of the practices and the ethos of the military.
If not, then the Defense Department refuses to grant permission to film at a base or to rent out US tanks or aircraft for a production.
To the Pentagon's critics, the arrangement amounts to stealthy propaganda, with the military using its leverage to effectively censor screenplays.
"They make prostitutes of us all because they want us to sell out to their point of view," director Oliver Stone told author David Robb in the book "Operation Hollywood," which blasts the Pentagon's role.
"Most films about the military are recruiting posters," the director said.
It is out of the question for the Pentagon to assist movies with a sadistic drill sergeant, like a memorable character in "Full Metal Jacket," or the reckless, rule-breaking soldier in "The Hurt Locker," officials said.
"I wouldn't claim pure innocence to the notion of trying to shape military portrayals so that they come a little closer to what we believe is the real military," Strub told AFP.
Hollywood heavyweight Jerry Bruckheimer, producer of "Black Hawk Down," "Top Gun" and "Pearl Harbor," said the horse-trading with the Pentagon is about finding a practical compromise.
"If we feel it's hurting the integrity of the film, then we won't do it. And if they think it's going to hurt their image, then they won't do it," he said in "Operation Hollywood."
"So there are certain ways to change things, to change wording that they'll feel comfortable with and you'll get what you want."
Sometimes attempts at compromise fail, and movie makers have to spend more cash tracking down old US-made military equipment in foreign countries.
Kevin Costner clashed with the Pentagon over the script of "Thirteen Days," a film recounting the Cuban missile crisis.
Defense officials objected to the portrayal of Air Force chief General Curtis LeMay as a bellicose hawk, a description shared by most historians. But the Pentagon wanted his character depicted in a more positive light.
As a result, the production had to be moved to the Philippines at great cost.
Ties between the Pentagon and Hollywood frayed in the aftermath of the unpopular Vietnam War, and most movies about that conflict received no assistance from the military, including Stone's "Platoon" and Francis Ford Coppola's "Apocalypse Now."
But the release of the gung-ho fighter pilot movie "Top Gun" in 1986 was a watershed, reflecting a shift in American attitudes and a resurgence of collaboration between the Pentagon and Hollywood.
Strub's office receives dozens of proposals every year, and fewer than half get the green light.
He and his small team spend much of their time reading through scripts, looking for scenes or characters that are unrealistic, inaccurate or inappropriate.
But he dismissed the idea that the Pentagon coerces movie makers into sanitizing screenplays.
"The whole idea that we can force these creative people to do our bidding is quite hilarious," he said. "There are people who won't come to us just because they don't want the perceived taint of having even talked to us."