The libretto was written by Lorenzo Da Ponte based on a stage comedy by Pierre Beaumarchais, La folle journée, ou le Mariage de Figaro (1784).