When Navy flyboy Tom Cruise got too close for missiles and switched to guns in the spring of 1986, what seemed like an entire nation got up to follow him. Military recruitment booths popped up in theaters, eager to attract young Americans who’d just seen Maverick tell Charlie about the inverted dive he’d done at four Gs against a MiG-28.

To say “Top Gun” was a boon for recruitment would be an understatement. That year, the Navy signed up 16,000 more people than it did the entire year before, according to the author Richard Parker, writing for Proceedings, the U.S. Naval Institute’s monthly magazine. Other estimates suggest that among naval aviators alone, this spike in registrations amounted to growth rates of 500 percent.

“Top Gun” didn’t just leave a lasting impression on thousands of would-be sailors and airmen; for Hollywood, the swashbuckling film marked a watershed moment for military-entertainment collaboration. The two have worked together since at least the 1920s, but the release of “Top Gun” led the mutually beneficial relationship to new heights.

[Graphic: Explore animated photos taken on the Apollo missions]

Now the film industry is rediscovering another patron of the arts — one whose mandate is less about fighting for country than it is about fighting for knowledge. Enter NASA, whose fictional adventures in outer space are the subject of Ridley Scott’s gripping new survival drama, “The Martian.”

Raking in over $100 million its opening weekend around the world, the film starring Matt Damon as an astronaut stranded on the red planet taps into a deepening well of public interest for all things space-related. Part of this has to do with some of the exciting things happening in private spaceflight. But when it comes to studying the stars, NASA is still tops. It knows this. And it’s using every tool in its media arsenal to take advantage of its time in the spotlight.

With “The Martian,” NASA has the same opportunity defense officials had in the 1980s, only now with additional social media superpowers. By highlighting everything from the real-world technologies depicted in “The Martian” to explaining the science behind Martian dust storms to calling on young women to take after the fictional Ares III mission commander, Melissa Lewis, NASA’s hoping to turn moviegoers into the nation’s next generation of scientists, technologists and the other all-around bad-ass eggheads celebrated in the film. In the run-up to the movie's release, NASA even made a major announcement about the discovery of liquid water on Mars that some believed was simply too conveniently timed to be a coincidence.

Never mind that “The Martian” begins with what is essentially a colossal embarrassment for NASA: A series of events that causes Ares III crewmember Mark Watney to be left for dead on Mars. Watney’s subsequent struggle to survive, and NASA’s feverish attempts to rescue him, turn what would otherwise be an agency disgrace into a massive coup for science and humanity.

The story of “The Martian,” adapted from the novel by Andy Weir, is unquestionably friendly to NASA. Even if it weren’t, a spokesperson told the Guardian, the agency doesn’t make a habit of altering scripts.

That’s a break from the long and controversial history of what some critics have called the military-entertainment complex, a close association between the armed forces and Hollywood that more or less made the Defense Department a gatekeeper for action movies. After “Top Gun,” the columnist David Sirota explains, the Pentagon shrewdly began using its cooperation as a kind of leverage against filmmakers. If your script didn’t portray the troops in a favorable light, you could forget about getting access to the ships, tanks and bases that served as your props and sets.

“The result is an entertainment culture rigged to produce relatively few antiwar movies and dozens of blockbusters that glorify the military,” Sirota wrote.

The tension in that relationship grew increasingly evident over the last decade as regular Americans — faced with the painful costs of two unpopular U.S.-led conflicts — struggled to reconcile the gap between war as it often appeared in theaters, and what was happening in actual theaters of war.

NASA’s involvement in Hollywood carries little of this political baggage. It primarily consults on scientific accuracy. Its top mission is education. And, notably, it doesn't have any military hardware to dangle in front of filmmakers. Indeed, what "The Martian" has to say about international politics might baffle military types: A key plot point involves an implausible but inspiring bit of international cooperation with a U.S. frenemy.

In producing "The Martian," filmmakers were treated not to displays of weapons systems but a behind-the-scenes tour of Johnson Space Center. They got interviews with real NASA scientists and astronauts who answered hundreds of questions about the way ion engines and artificial gravity really work. Against the backdrop of the military-entertainment complex, all this makes the prospect of a deeper relationship between NASA and the film industry seem relatively non-threatening.

The agency isn’t a stranger to the film industry, of course: It’s played a part in such unlikely movies as “Armageddon,” “Men In Black III” and the Transformers franchise. But none of those films did much to inspire young people to go into science, technology, math or engineering — the so-called STEM fields that tech experts say must be cultivated if the United States expects to remain a global leader.

“The Martian” is different. For the first time since "Apollo 13," moviegoers are getting to see a scientific government agency as a leading character — a hero, even. It lays the groundwork for a science-entertainment complex at a scale we've never seen. Three decades after Maverick buzzed the tower against orders, NASA is finally catching up to the Pentagon.