In 1731 Pergolesi was given the task of setting a complete dramma sacro to music as the final composition of his studies at the Conservatorio.
The young Leonardo Leo and Francesco Feo had faced similar tests at the Conservatorio della Pietà dei Turchini almost twenty years earlier.
The libretto, supplied by the lawyer Mancini (although described as "anonymous" in the oldest surviving manuscript), concerned the legendary figure of Saint William of Aquitaine, and was set at the time of the religious struggles between Pope Innocent II and the Antipope Anacletus II.
In fact, as Lucia Fava explains in her review of the production in Jesi in 2016:
If the plot takes its starting point from an historical event, the internal conflict in the Church between Anacletus and Innocent, the character of San Guglielmo is based on the biographies of three different "Williams": William X Duke of Aquitaine and Count of Poitiers, who really was associated with the historical Saint Bernard of Clairvaux; William of Gellone, another Duke of Aquitaine, who after a life dedicated to warfare and fighting against the Saracens retired to become a monk; and William of Maleval, who crowned his life devoted to heresy and lust with a pilgrimage to Jerusalem and retreat to a hermitage.
The conflation of these three figures is the result of a hagiographical tradition which was already well established by the time the libretto was written and was not Mancini's invention.

There are seven characters in the drama, five of them - those of a more elevated social rank and with more spiritual characteristics - are entrusted to higher voices (sopranos).
The sources are unclear whether this means castrati or female singers.
The remaining two roles, that of the plebeian captain Cuòsemo - a soldier in the entourage of the Duke of Aquitaine who follows his master's path to salvation, although reluctantly - and that of the Devil, are entrusted to bass voices.
The character of Alberto, who probably corresponds to the historical figure of William of Maleval's favourite disciple, only has a few bars of recitative in the third act (in fact this character does not even appear in the cast list of the staging in Jesi in 2016).
The characters of Saint Bernard and Father Arsenio appear at different moments in the drama (in the first and second act respectively) and were probably intended to be sung by the same performer, making his contribution equal in importance to the other roles: each character has three arias, reduced to two for the title character and increased to four for the more virtuosic role of the angel.
In the score in the Biblioteca Giovanni Canna in Casale Monferrato, which follows the libretto of the oratorio version published in Rome in 1742 to the letter, there is also a third aria for Guglielmo, which would "restore the balance" in favour of the theoretically most important character but, according to Catalucci and Maestri, it is difficult to fit this piece into the dramatic action of the Naples manuscript.

The whole opera, not counting the additional aria for Guglielmo, is made up of the following parts:
a sinfonia before the opera,
15 arias,
four duets,
a quartet,
secco recitatives
two accompanied recitatives
In 1731 Pergolesi was given the task of setting a complete dramma sacro to music as the final composition of his studies at the Conservatorio. The young Leonardo Leo and Francesco Feo had faced similar tests at the Conservatorio della Pietà dei Turchini almost twenty years earlier. The libretto, supplied by the lawyer Mancini (although described as "anonymous" in the oldest surviving manuscript), concerned the legendary figure of Saint William of Aquitaine, and was set at the time of the religious struggles between Pope Innocent II and the Antipope Anacletus II. In fact, as Lucia Fava explains in her review of the production in Jesi in 2016:
If the plot takes its starting point from an historical event, the internal conflict in the Church between Anacletus and Innocent, the character of San Guglielmo is based on the biographies of three different "Williams": William X Duke of Aquitaine and Count of Poitiers, who really was associated with the historical Saint Bernard of Clairvaux; William of Gellone, another Duke of Aquitaine, who after a life dedicated to warfare and fighting against the Saracens retired to become a monk; and William of Maleval, who crowned his life devoted to heresy and lust with a pilgrimage to Jerusalem and retreat to a hermitage. The conflation of these three figures is the result of a hagiographical tradition which was already well established by the time the libretto was written and was not Mancini's invention.
There are seven characters in the drama, five of them - those of a more elevated social rank and with more spiritual characteristics - are entrusted to higher voices (sopranos). The sources are unclear whether this means castrati or female singers. The remaining two roles, that of the plebeian captain Cuòsemo - a soldier in the entourage of the Duke of Aquitaine who follows his master's path to salvation, although reluctantly - and that of the Devil, are entrusted to bass voices. The character of Alberto, who probably corresponds to the historical figure of William of Maleval's favourite disciple, only has a few bars of recitative in the third act (in fact this character does not even appear in the cast list of the staging in Jesi in 2016). The characters of Saint Bernard and Father Arsenio appear at different moments in the drama (in the first and second act respectively) and were probably intended to be sung by the same performer, making his contribution equal in importance to the other roles: each character has three arias, reduced to two for the title character and increased to four for the more virtuosic role of the angel. In the score in the Biblioteca Giovanni Canna in Casale Monferrato, which follows the libretto of the oratorio version published in Rome in 1742 to the letter, there is also a third aria for Guglielmo, which would "restore the balance" in favour of the theoretically most important character but, according to Catalucci and Maestri, it is difficult to fit this piece into the dramatic action of the Naples manuscript.
The whole opera, not counting the additional aria for Guglielmo, is made up of the following parts:
a sinfonia before the opera,
15 arias,
four duets,
a quartet,
secco recitatives
two accompanied recitatives
La conversione e morte di San Guglielmo