Though the text is straight from Scripture, the prayer itself doesn't go back as long as you might think.
In the Gospel of Luke, we find the two principal verses that make up the frequently used “Hail Mary” prayer. The first part of the prayer is derived from the Annunciation, when the angel Gabriel greeted Mary by saying, “Hail, full of grace, the Lord is with you!” (Luke 1:28) The next part of the prayer is taken from the Visitation, when Elizabeth greeted Mary with the words, “Blessed are you among women, and blessed is the fruit of your womb!” (Luke 1:42)
However, while the prayer is essentially straight from the Bible, Christians did not put the two verses together until the 11th century. The Catholic Encyclopedia explains, “In point of fact there is little or no trace of the Hail Mary as an accepted devotional formula before about 1050. All the evidence suggests that it took its rise from certain versicles and responsories occurring in the Little Office or Cursus of the Blessed Virgin which just at that time was coming into favor among the monastic orders. Two Anglo-Saxon manuscripts at the British Museum, one of which may be as old as the year 1030, show that the words ‘Ave Maria’ etc. and ‘benedicta tu in mulieribus et benedictus fructus ventris tui’ occurred in almost every part of the Cursus, and though we cannot be sure that these clauses were at first joined together so as to make one prayer, there is conclusive evidence that this had come to pass only a very little later.”
At first the prayer was known as the “Salutation of the Blessed Virgin,” and only consisted of the two verses joined together. It was not until much later that the second petitionary half of the prayer (the Holy Mary part) was added. For several centuries the prayer simply ended at “…blessed is the fruit of thy womb, Jesus. Amen,” but sometimes included different petitions that were added on after that.
The official prayer of the “Ave Maria” was not finalized until after the publication of the Catechism of the Council of Trent and the prayer was then included in the Roman Breviary of 1568. In the Catechism of Trent the prayer is mentioned, still referred to as the “Angelical Salutation.”
“The first part of the Angelical Salutation. When we say by way of prayer: “Hail Mary, full of grace, the Lord is with thee, blessed art thou among women,” we render to God the highest praise and return him most grateful thanks, because he accumulated all his heavenly gifts on the most Holy Virgin ; and to the Virgin herself, for this her singular felicity, we present our respectful and fervent congratulations.
“To this form of thanksgiving the church of God has wisely added prayers to, and an invocation of, the most holy Mother of God, by which we piously and humbly fly to her patronage, in order that, by interposing her intercession, she may conciliate the friendship of God to us miserable sinners, and may obtain for us those blessings which we stand in need of in this life and in the life to come. Exiled children of Eve, who dwell in this vale of tears, should we not earnestly beseech the Mother of mercy, the advocate of the faithful, to pray for us? Should we not earnestly implore her help and assistance?”
The prayer is now a central pillar of Catholic devotion. It expresses our love for the Blessed Virgin Mary using words from Scripture and then asks for her assistance in our hour of need. It is a beautiful prayer, one that has a history going back at least one thousand years.