The Pinafore, a "saucy" beauty of a ship in her majesty's navy is anchored in the harbor at Portsmouth. Its proud sailors are busy scrubbing the decks for the expected arrival of Sir Joseph Porter, K.C.B., Britain's First Lord of the Admiralty. "Little" Buttercup, a bumboat woman who is "red and round and rosy" comes aboard to sell to the sailors her stock of "snuff and tobaccy and excellent jacky," and other luxuries.
A handsome and accomplished sailor, Ralph, tells his messmates that he is in love with the Captain's daughter, Josephine. Dick Deadeye, the embodiment of the ugly truth, reminds the starry-eyed seaman that Captain's daughters don't marry foremast hands! The Captain arrives to inspect his crew. The gentleman captain sings that he never uses foul language and is never sick at sea--well, "hardly ever."
Josephine is sought in marriage by Sir Joseph, but it seems that she has no enthusiasm for a union with that cabinet minister--secretly, she is in love with a lowly sailor: Ralph. It also seems that Little Buttercup has a romantic interest in the Captain and harbors a secret about Ralph!
Finally, Sir Joseph arrives attended by his many "sisters and his cousins and his aunts," among whom is his loyal but jealous cousin Hebe. He explains that he rose to the top post in the Navy by sticking close to his desk and never going to sea. He also encourages the Captain to request that his sailors follow an order with the phrase "if you please." After all, his Lordship notes, "a British sailor is any man's equal." Indeed, he presents the crew with a song that he himself has composed to encourage "independence of thought and action in the lower branches" of the Navy. Sir Joseph and the Captain retire below decks to discuss the proposed marriage.
Ralph finds Josephine alone on deck and declares his love for her and his willingness to try to fit in with middle-class society. She rejects his proffered love, although his simple eloquence goes to her heart. She is a dutiful daughter and cannot forget the disparity in their ranks. But when Ralph threatens suicide, the lady relents and declares her love for him. With the crew and the sisters, cousins and aunts assisting, the lovers plot to elope that very night. Dick Deadeye warns the pair of the impropriety of their plan, but he is forced to retreat.
Captain Corcoran is alone on deck with his guitar and sings to the moon of his troubles. Little Buttercup comes to him and reveals her affection. He tells her that because of his rank he can never be more to her than a friend; but she hints darkly that a change is in store for him, and "things are seldom what they seem."
Sir Joseph returns, complaining that Josephine does not favor his suit. The Captain comforts him by theorizing that she is dazzled by his lofty station and suggests that he plead his cause on the ground that "love levels all ranks". When Josephine hears this argument, she considers how eloquently Sir Joseph has stated the justification for her to marry Ralph!
Dick Deadeye finds the Captain alone and reveals the planned elopement. He and the Captain lie in wait for the crew, who steal in "carefully on tip-toe." The Captain confronts the elopers and is so exasperated that he actually swears a foul oath: "Damme!" which is overheard by Sir Joseph Porter. Judging first and asking questions later, Sir Joseph orders the Captain to go to his cabin for this "ill-advised asperity."
Upon inquiry, Sir Joseph finds out that Ralph and Josephine love one another and orders the "presumptuous" sailor to the brig. Affairs are interrupted by Little Buttercup, who discloses her long-concealed secret: As their foster mother, she had accidentally exchanged the Captain and Ralph while they were both babies.
Sir Joseph immediately sends for Ralph (who is now Captain) and the Captain (who is now a humble seaman). Since it is "out of the question" for Sir Joseph to marry the daughter of a mere sailor, his Lordship nobly consents to the marriage of Ralph and Josephine. The former Captain is now free to marry dear Little Buttercup, and Sir Joseph agrees to marry his longtime admirer, cousin Hebe. All ends with "joy and rapture unforseen," for "he is an Englishman!" Hip, Hip, Horray!