The story concerns Frederic, who, having completed his 21st year, is released from his apprenticeship to a band of tender-hearted pirates. He meets Mabel, the daughter of Major-General Stanley, and the two young people fall instantly in love. Frederic soon learns, however, that he was born on the 29th of February, and so, technically, he has a birthday only once each leap year. His indenture specifies that he remain apprenticed to the pirates until his "twenty-first birthday", meaning that he must serve for another 63 years. Bound by his own sense of duty, Frederic's only solace is that Mabel agrees to wait for him faithfully.
Pirates was the fifth Gilbert and Sullivan collaboration and introduced the much-parodied "Major-General's Song". The opera was performed for over a century by the D'Oyly Carte Opera Company in Britain and by many other opera companies and repertory companies worldwide. Modernized productions include Joseph Papp's 1981 Broadway production, which ran for 787 performances, winning the Tony Award for Best Revival and the Drama Desk Award for Outstanding Musical, and spawning many imitations and a 1983 film adaptation. Pirates remains popular today, taking its place along with The Mikado and H.M.S. Pinafore as one of the most frequently played Gilbert and Sullivan operas.
The Pirates of Penzance was the only Gilbert and Sullivan opera to have its official premiere in the United States. At the time, American law offered no copyright protection to foreigners. After the pair's previous opera, H.M.S. Pinafore, achieved success in London in 1878, approximately 150 American companies quickly mounted unauthorised productions that often took considerable liberties with the text and paid no royalties to the creators. Gilbert and Sullivan hoped to forestall further "copyright piracy" by mounting the first production of their next opera in America, before others could copy it, and by delaying publication of the score and libretto. They succeeded in keeping for themselves the direct profits of the first American production of The Pirates of Penzance by opening the production themselves on Broadway, prior to the London production, and they also operated profitable US touring companies of Pirates and Pinafore. However, Gilbert, Sullivan, and their producer, Richard D'Oyly Carte, failed in their efforts, over the next decade, to control the American performance copyrights to Pirates and their other operas.
Fiction and plays about pirates were ubiquitous in the 19th century. Walter Scott's The Pirate (1822) and James Fenimore Cooper's The Red Rover were key sources for the romanticised, dashing pirate image and the idea of repentant pirates. Both Gilbert and Sullivan had parodied these ideas early in their careers. Sullivan had written a comic opera called The Contrabandista, in 1867, about a hapless British tourist who is captured by bandits and forced to become their chief. Gilbert had written several comic works that involved pirates or bandits. In Gilbert's 1876 opera Princess Toto, the title character is eager to be captured by a brigand chief. Gilbert had translated Jacques Offenbach's operetta Les brigands, in 1871. As in Les brigands, The Pirates of Penzance absurdly treats stealing as a professional career path, with apprentices and tools of the trade such as the crowbar and life preserver.
While Pinafore was running strongly at the Opera Comique in London, Gilbert was eager to get started on his and Sullivan's next opera, and he began working on the libretto in December 1878. He re-used several elements of his 1870 one-act piece, Our Island Home, which had introduced a pirate "chief", Captain Bang. Bang was mistakenly apprenticed to a pirate band as a child by his deaf nursemaid. Also, Bang, like Frederic in The Pirates of Penzance, had never seen a woman before and felt a keen sense of duty, as an apprenticed pirate, until the passage of his twenty-first birthday freed him from his articles of indenture. Bernard Shaw believed that Gilbert drew on ideas in Les brigands for his new libretto, including the businesslike bandits and the bumbling police. Gilbert and Sullivan also inserted into Act II an idea they first considered for a one-act opera parody in 1876 about burglars meeting police, while their conflict escapes the notice of the oblivious father of a large family of girls. As in Pinafore, "there was a wordful self-descriptive set-piece for Stanley , introducing himself much as Sir Joseph Porter had done ... a lugubrious comic number for the Sergeant of Police ... a song of confession for Ruth, the successor Little Buttercup", romantic material for Frederic and Mabel, and "ensemble and chorus music in turn pretty, parodic and atmospheric."