Beaumarchais's earlier play The Barber of Seville had already made a successful transition to opera in a version by Paisiello. Although Beaumarchais's Marriage of Figaro was at first banned in Vienna because of its licentiousness, Mozart's librettist managed to get official approval for an operatic version which eventually achieved great success.
The opera was the first of three collaborations between Mozart and Da Ponte; their later collaborations were Don Giovanni and Così fan tutte. It was Mozart who originally selected Beaumarchais's play and brought it to Da Ponte, who turned it into a libretto in six weeks, rewriting it in poetic Italian and removing all of the original's political references. In particular, Da Ponte replaced Figaro's climactic speech against inherited nobility with an equally angry aria against unfaithful wives. Contrary to the popular myth, the libretto was approved by the Emperor, Joseph II, before any music was written by Mozart.
The Imperial Italian opera company paid Mozart 450 florins for the work; this was three times his (low) salary for a year, when he had worked as a court musician in Salzburg. Da Ponte was paid 200 florins.