The Roman Catechism (1566) says this:
For The Blessed Virgin Mary
To this sort of prayer belongs the first part of the Angelic Salutation, when used by us as a prayer: Hail Mary, full of grace, the Lord is with thee, blessed art thou among women. For in these words we render to God the highest praise and return Him most gracious thanks, because He has bestowed all His heavenly gifts on the most holy Virgin; and at the same time we congratulate the Virgin herself on her singular privileges.
To this form of thanksgiving the Church of God has wisely added prayers and an invocation addressed to the most holy Mother of God, by which we piously and humbly fly to her patronage, in order that, by her intercession, she may reconcile God to us sinners and may obtain for us those blessings which we stand in need of in this life and in the life to come. We, therefore, exiled children of Eve, who dwell in this vale of tears, should constantly beseech the Mother of mercy, the advocate of the faithful, to pray for us sinners. In this prayer we should earnestly implore her help and assistance; for that she possesses exalted merits with God, and that she is most desirous to assist us by her prayers, no one can doubt without impiety and wickedness.
The second part of the prayer seems to have been added sometime during the late Middle Ages.