Mascagni (center) with his librettists, Giovanni Targioni-Tozzetti (left) and Guido Menasci
In July 1888 the Milanese music publisher
Edoardo Sonzogno announced a competition open to all young Italian composers who had not yet had an opera performed on stage. They were invited to submit a one-act opera which would be judged by a jury of five prominent Italian critics and composers. The best three would be staged in Rome at Sonzogno's expense.
Mascagni heard about the competition only two months before the closing date and asked his friend Giovanni Targioni-Tozzetti, a poet and professor of literature at the
Italian Royal Naval Academy in
Livorno, to provide a libretto. Targioni-Tozzetti chose Cavalleria rusticana, a popular short story (and play) by
Giovanni Verga, as the basis for the opera. He and his colleague Guido Menasci set about composing the libretto, sending it to Mascagni in fragments, sometimes only a few verses at a time on the back of a postcard. The opera was finally submitted on the last day that entries would be accepted. In all, 73 operas were submitted, and on 5 March 1890, the judges selected the final three:
Niccola Spinelli's Labilia, Vincenzo Ferroni's Rudello, and Mascagni's Cavalleria rusticana.
There have been two other operas based on Verga's story. The first,
Mala Pasqua! (Bad Easter!) by
Stanislao Gastaldon, was entered in the same competition as Mascagni's. However, Gastaldon withdrew it when he received an opportunity to have it performed at the Teatro Costanzi, where it premiered on 9 April 1890.
 In the 1907 Sonzogno competition,
Domenico Monleone submitted an opera based on the story, and likewise called Cavalleria rusticana. The opera was not successful in the competition, but premiered later that year in Amsterdam and went on to a successful tour throughout Europe, ending in Turin. Sonzogno, wishing to protect the lucrative property which Mascagni's version had become, took legal action and successfully had Monleone's opera banned from performance in Italy.
 Monleone changed the opera ‘beyond recognition’, setting the music to a new libretto. In this form it was presented as La giostra dei falchi in 1914.