John J. Baggs, Jr. [James Caan] is a U.S. Navy sailor and Vietnam veteran who checks into the Seattle naval base medical facility for treatment of a pilonidal cyst. His medical test results are delayed, preventing him from rejoining his ship when it sails. He receives a clean bill of health, but must wait at the base for reassignment to another ship, and is granted a Cinderella liberty pass that allows him to come and go from the base until the midnight curfew. Soon after, the base loses his records, making him unable to be reassigned or receive pay or benefits, keeping him stuck at the base on Cinderella liberty until his records are found.
On his first night in a bar, he races the clock to find a woman before midnight, and is drawn to Maggie Paul [Marsha Mason], a prostitute hustling sailors at a pool table. He challenges her at pool, and later goes to her tenement apartment for a sexual encounter, discovering that she lives with her bi-racial 11-year-old son, Doug [Kirk Calloway]. Baggs lectures Maggie about her lack of motherly oversight towards her son, noticing that Doug is often left to fend for himself. He begins spending time with him, while also developing a relationship with Maggie, with whom he is falling in love. The couple almost break up when Baggs learns Maggie is pregnant by a man she knew before she met Baggs, but they reconcile and Baggs accepts responsibility for the unborn child.
At the base, Baggs runs into his former training instructor, the brutal older sailor Lynn Forshay [Eli Wallach]. After an initial fistfight, Baggs learns Forshay has been demoted and is being discharged due to his mistreatment of recruits, one of whom had political connections. Forshay’s love of the Navy has been the only constant in his life and Forshay has no family or relationships outside the Navy. Baggs feels sorry for him and becomes his friend, while not wanting to repeat the same pattern in his own life. After his discharge, Forshay loses his pension and is forced to take a menial job as a strip show barker.
Baggs attempts to create a normal family life for Maggie and Doug, and succeeds for a while despite the obstacles presented by his lack of pay and benefits. He and Maggie marry, but due to his lost records, the Navy refuses to recognize the marriage or grant Maggie and Doug the normal privileges given to a sailor's family. Doug, suspicious and cynical at first, bonds with Baggs, who manages to get Doug’s painfully decayed teeth fixed at the naval base by an unqualified dental assistant. Maggie gives birth prematurely to a son, whom she names after Baggs, but the baby dies soon after birth, causing a distraught Maggie to return to prostitution in order to distract herself from her grief. The Navy finally locates Baggs’s records and reassigns him to a new ship, also giving him $1,400 in back pay. When he goes to tell Maggie, he finds she has departed for New Orleans with another man, and left Doug behind for Baggs to look after. In order to stay with Doug, Baggs gets Forshay to change places with him and ship out under his name. After waving goodbye to a hopeful Forshay, Baggs and Doug then head for New Orleans to look for Maggie.