Lieutenant Commander Thomas Dodge (Kelsey Grammer), a capable (if somewhat unorthodox) US Navy officer, is about to be denied command of his own submarine for a third time because of his unconventional ways (not to mention a widely known tattoo on his penis reading "Welcome aboard!' that he'd gotten after getting drunk due to brushing his sub against a Russian trawler off Murmansk). Failure to secure a command will result in him being dropped from the command program and be assigned a desk job, and he is particularly opposed by Rear Admiral Yancy Graham (Bruce Dern). Vice Admiral Dean Winslow (Rip Torn) finds the perfect use for Dodge, however, when Winslow launches a war-game to test the Navy's defenses against enemy diesel submarines. For this purpose Dodge gains command of the rusty WWII era Balao-class diesel sub, the USS Stingray. Adm. Winslow gives Dodge the order to "throw the book out" and to "think like a pirate" and advises that if he can win the war-game, including sinking a mock target in Norfolk harbor, Winslow will consider Dodge for command of a nuclear submarine.Adm. Graham, motivated by his dislike for Dodge and his own ambition (he brags that he has never lost a war-game, and that he is in line for a third star), tries to arrange circumstances to make Dodge's mission even more difficult. Graham handpicks a motley crew for the Stingray consisting of rejects and misfits: hot-tempered and uptight Executive Officer Martin Pascal (Rob Schneider), rebellious Engineman 1st Class Brad Stapanek, sharp-eared Sonar Technician 2nd Class E.T. "Sonar" Lovacelli, compulsive gambler Seaman Stanley "Spots" Sylvesterson, shock-prone (and shock-addled) electrician Seaman Nitro, and the not-so-culinary cook Seaman Buckman. Graham also institutes a pilot program for evaluating the feasibility of women serving on submarines, and Lieutenant Emily Lake (Lauren Holly) joins the crew as Diving Officer.Using unorthodox tactics to offset their technological disadvantage, Dodge and the Stingray crew win their first objective by getting into and setting off flares in Charleston Harbor. Desperate to defeat Dodge, Graham cuts the containment area for the wargame in half without authorization. Running into trouble on their first attempt at Norfolk harbor, Dodge leaves the exercise area. Irate at this lapse in protocol, the zealous by-the-book Pascal attempts to gain command of the Stingray, but no one supports him. Without support, his attempt is considered mutiny and, thinking like a pirate, Dodge makes him walk the plank, straight into the nets of an alongside fishing boat.During the Stingray's second attempt at Norfolk, Graham assumes personal command of the Los Angeles-class USS Orlando, headed by Commander Carl Knox (William H. Macy). After some risky maneuvers by the Stingray, the Orlando is able to chase her down and obtain a shooting solution which ends the game, but not before the Stingray accurately launched two live torpedoes at the dummy ship in Norfolk harbor.Adm. Winslow congratulates Dodge on a job well done and advises him that he will not get a Los Angeles-class submarine as requested, but a Seawolf-class submarine, which is a newer and much larger ship. Dodge rejects the notion of getting a "proper crew" with the new boat and requests that he be allowed to transfer the crew of the Stingray. The movie ends with The Village People and the movie cast singing and dancing to 'In the Navy'.