Ave Maria is an old Latin text from the Catholic Church. It came about from the "Hail Mary."
The original Latin text is: Ave Maria, gratia plena, Dominus tecum
Which translates to: Hail Mary, full of grace, the Lord is with thee
The popular "Ave Maria" tune typically heard at weddings and the such, is written by Franz Shubert. The actual name of the piece is: Ellens Gesang III ("Ave Maria"), D. 839 (Op. 52/6) Ave Maria.
There is some speculation on the origin of the melody. Typically, composers will borrow pre-composed melodys and adapt them for their own purposes. This happend with "Ave Maria," as the original tune was originally composed by Walter Scott.
More information can be found here: http://en.wikipedia.org/wiki/Ellens_dritter_Gesang
Hope it helps!