One day, after celebrating Mass, the aged Pope Leo XIII was in conference
with the Cardinals when suddenly he sank to the floor in a deep swoon.
Physicians who hastened to his side could find no trace of his pulse and feared
that he had expired. However, after a short interval the Holy Father regained
consciousness and exclaimed with great emotion: "Oh, what a horrible picture I
have been permitted to see!"

He had been shown a vision of evil spirits who had been released from Hell and
their efforts to destroy the Church. But in the midst of the horror the
archangel St. Michael appeared and cast Satan and his legions into the abyss of
hell. Soon afterwards Pope Leo XIII composed a prayer to St. Michael, imploring
his protection for the Church.

Many are familiar with the short form of this prayer, which used to be recited at the foot of the altar after low Masses prior to the post-Vatican II changes to the Mass. It is commonly recited after the rosary and at following Extraordinary Form Masses.

There is also a longer form of the prayer which is most commonly used for exorcisms.