Lully then collaborated with Molière on a series of "comédies-ballets" which culminated in "Le bourgeois gentilhomme" (1670). After that he turned to opera, securing the privilege previously granted to Perrin and forestalling potential rivals with oppressive patents granted by the king. He chose as librettist Philippe Quinault, with whom he succeeded in establishing a new and essentially French type of opera known as "tragédie lyrique". Between 1673 and 1686 Lully composed 13 such works, 11 of them with Quinault.
During this time Lully continued to enjoy the king's support, despite Louis' displeasure at his overt homosexual behaviour and the resentment his high-handedness provoked in other musicians. His greatest personal triumph came in 1681 when in an impressive ceremony he was received as "secrétaire du Roi". After the king's marriage to Mme de Maintenon in 1683 life at court took on a new sobriety; it was perhaps in response to this that Lully composed much of his religious music. During a performance of his "Te Deum" in January 1687 he injured his foot with the point of a cane he was using to beat time. Gangrene set in, and within three months he died, leaving a "tragédie lyrique", "Achille et Polyxène", unfinished.
At his death Lully was widely regarded as the most representative of French composers. Practically all his music was designed to satisfy the tastes and interests of Louis XIV. The "ballets de cour" (1653-63) and the "comédies-ballets" (1663-72) were performed as royal entertainments, the king himself often taking part in the dancing. The "tragédies lyriques" (1673-86) were kingly operas "par excellence", expressing a classical conflict between "la gloire" and "l'amour"; Louis himself supplied the subject matter for at least four of them and certainly approved the political sentiments of the prologues. Lully's music was correspondingly elevated, in the stately overtures, the carefully moulded 'récitatif simple' and the statuesque choruses; many of the airs, too, draw as much attention to the "galant" mores of the court as to the stage action. Finally, the Versailles "grand motet", of which the "Miserere" is an outstanding example, was designed to glorify the King of France as much as the King of Heaven.