Catholic and Eastern Orthodox tradition both formally teach the doctrine of Mary as “ever-Virgin,” meaning that she didn’t have sex with anyone, including her husband Joseph, throughout her life.
The doctrine also includes the notion that she remained a virgin even through the birth of Jesus, meaning that her hymen was not ruptured through childbirth.
Jaroslov Pelikan, in Mary Through the Centuries, tells us that the doctrine got lift-off in part through an allegorical reading of an obscure passage in the Song of Solomon.
There is no explicit testimony to Mary’s “perpetual virginity” in the Bible. Furthermore, the gospels seem to mention that Jesus had siblings. Pelikan summarizes that,
The apparently obvious and natural conclusion from this would seem to have been that after the miraculous conception of Jesus by the power of the Holy Spirit, Mary and Joseph went on to have other children of their own.
But that was not the conclusion that the vast majority of early Christian teachers drew. Instead, they came to call Mary Ever-Virgin, Aeiparthenos, Semper Virgo. To do this in the light of the biblical materials about the “brethren” of Jesus, they had to resort to some elaborate biblical arguments. The biblical support for calling Mary Ever-Virgin, however, came not chiefly form the New Testament but from the Song of Songs: “A garden inclosed is my sister, my spouse; a spring shut up, a fountain sealed…
…An interesting process of creative interpretation was going on here. (29)
Aside from Scripture, non-canonical texts were extremely influential in the formulation of the doctrine: the Ascension of Isaiah, The Odes of Solomon, and the Protoevangelium of James.
Theologians as early as Irenaeus and Clement of Alexandria affirmed the doctrine. It has persevered through much of the history of the church, even affirmed by Martin Luther and later, by John Wesley. It has persevered still today in several Christian traditions.