United States Naval Aviator Lieutenant Pete "Maverick" Mitchell (Tom Cruise) flies an F-14A Tomcat off USS Enterprise (CVN-65), with Nick "Goose" Bradshaw (Anthony Edwards) as his Radar Intercept Officer (RIO). Maverick and his wingman "Cougar" (John Stockwell) intercept (fictional) MiG-28s over the Indian Ocean. During the standoff, one of the MiGs manages to get a missile lock on Cougar. Maverick realizes that the MiG is only trying to intimidate Cougar and drives it off, but Cougar is too shaken afterward to land. Maverick defies orders and shepherds Cougar back to the carrier as both planes run critically low on fuel. After they land, Cougar takes himself off flight status. Although disapproving of Maverick's reckless flying and repeated violations of rules, the Enterprise's CAG "Stinger" (James Tolkan) sends Maverick and Goose—now his top crew—to attend the Navy's Fighter Weapons School, known as "Top Gun", at NAS Miramar.
Maverick's recklessness is partly due to his father, Duke Mitchell, who served with the VF-51 squadron aboard the USS Oriskany (CV-34) during the Vietnam War, and was killed in action when his Phantom was shot down. The official story, which Maverick refuses to believe, is that Duke made a mistake. Goose is much more cautious and devoted to his wife, Carole (Meg Ryan), and child. The two officers are nonetheless close friends and effective partners, with Maverick considering Goose his only family. At a bar the day before the Top Gun program starts, Maverick, assisted by Goose, unsuccessfully approaches a woman named Charlotte "Charlie" Blackwood (Kelly McGillis), who he later learns is a civilian contractor with a Ph.D. in astrophysics serving as a Top Gun instructor.
Maverick's reckless flying both annoys and impresses Lieutenant Commander Rick "Jester" Heatherly (Michael Ironside) and other instructors. He defeats Jester in exercises, but violates two rules of engagement in the process and is strongly reprimanded by the chief instructor, Commander Mike "Viper" Metcalf (Tom Skerritt). Maverick continues to pursue Charlie and becomes a rival to top student Lieutenant Tom "Iceman" Kazanski (Val Kilmer), who considers Maverick's methods dangerous and unsafe. Although outwardly critical of Maverick's tactics, Charlie eventually admits that she admires his flying but was critical because she was afraid for her credibility. They begin a romantic relationship.
During one flight, Maverick goes one-on-one with Viper. Although Maverick matches the older pilot move for move, Viper lasts long enough for Jester to maneuver around and "shoot" Maverick down, demonstrating the value of teamwork over individual ability.
Near the end of the program, Maverick and Iceman both chase Jester. Under intense pressure from Maverick, Iceman breaks off. Maverick's F-14 flies through the jet wash of Iceman's aircraft and suffers a flameout of both engines, entering a flat spin from which he cannot recover, forcing both Maverick and Goose to eject. Goose ejects directly into the jettisoned aircraft canopy, which breaks his neck, killing him.
Although the board of inquiry clears Maverick of responsibility, he feels guilty for Goose's death, losing his aggressiveness when flying. Charlie and others attempt to console him, but Maverick considers leaving the Navy. Unsure of his future, he seeks Viper's advice. Viper reveals that he served with Maverick's father and discloses classified details over his last mission, explaining how Duke stayed in the fight after his Phantom was hit and saved three planes before he died. Information about the dogfight was classified to avoid revealing that the American planes were not where they should have been.
During the graduation party, Iceman, Hollywood, and Maverick are ordered to immediately report to the Enterprise to deal with a "crisis situation", providing air support for the rescue of a stricken communications ship that has drifted into hostile waters. Maverick and Merlin are assigned to one of two F-14s as back-up for those flown by Iceman and Hollywood, despite Iceman's reservations over Maverick's state of mind. Maverick is sortied alone due to catapult failure and nearly retreats after encountering circumstances similar to those that caused Goose's death. Upon rejoining Iceman, they shoot down four MiGs and force the others to flee, and return to the Enterprise, where the two men, with newfound respect for each other, finally become friends. Offered any assignment he chooses, Maverick decides to return to Top Gun as an instructor. Later, he tosses Goose's dogtags into the ocean, finally freeing himself of guilt over Goose's death.
Sitting alone in a restaurant in downtown San Diego, Maverick hears "You've Lost That Lovin' Feelin'" playing on the jukebox and recalls meeting Charlie. She reveals that she is in the bar and the two reunite.