From paragraph 499 in the Catechism of the Catholic Church:
The deepening of faith in the virginal motherhood led the Church to confess Mary's real and perpetual virginity even in the act of giving birth to the Son of God made man. In fact, Christ's birth "did not diminish his mother's virginal integrity but sanctified it."And so the liturgy of the Church celebrates Mary as Aeiparthenos, the "Ever-virgin".
The direct precedent is Canon 6 from the Second Council of Constantinople in 553 CE. The only source of this I know of is Denzinger's Sources of Catholic Dogma, a compilation of a ton of loose documents. Unfortunately, this is not available online in English, so you'll have to bear with the Latin. In paragraph 427:
Si quis abusive et non vere Dei genitricem dicit sanctam gloriosam semper Virginem Mariam, vel secundum relationem, quasi homine puro nato, sed non Deo Verbo incarnato et nato ex ipsa, referenda autem, sicut illi dicunt, hominis nativitate ad Deum Verbum, eo quod cum homine erat nascente, et calumniatur sanctam Chalcedonensem Synodum, tamquam secundum istum impium intellectum, quem Theodorus exsecrandus adinvenit, Dei genitricem Virginem dicentem, vel qui hominis genitricem vocat, aut Christotocon, id est, Christi genitricem, tamquam si Christus Deus non esset, et non proprie et vere Dei genitricem ipsam confitetur, eo quod ipse qui ante saecula ex Patre natus est Deus Verbum, in ultimis diebus ex ipsa incarnatus et natus est, et sic pie et sanctam Chalcedonensem Synodum eam esse confessam, talis an. s.
Here, the council decrees that anyone speaking against the Holy and Glorious ever-virgin Mary shall be anathema.
This was again affirmed in the Lateran Council of 649, from paragraph 503:
Si quis secundum sanctos Patres non confitetur proprie et secundum veritatem Dei genitricem sanctam semperque Virginem et immaculatam Mariam, utpote ipsum Deum Verbum specialiter et veraciter, qui a Deo Patre ante omnia saecula natus est, in ultimis saeculorum absque semine concepisse ex Spiritu Sancto, et incorruptibiliter eam (eum?) genuisse, indissolubili permanente et post partum eiusdem virginitate, condemnatus sit
The Catholic Encyclopedia also mentions several Church Fathers who spoke of the doctrine of the perpetual virginity of Mary.
At the time of the early Church, the burden of proof was on those to show that Mary was not ever-virgin, as it was commonly held to be true. Just for the sheer theatrical aspect of it, I particularly like St. Jerome's response to Helvidius, one who shared many of the objections held today about the perpetual virginity of Mary. In his response, he dissected the argument word by word and found the conclusion that Mary was not perpetually virgin did not necessarily follow from Biblical evidence:
Yet it does not follow, as the previous examples showed, that he had intercourse with Mary after her delivery, when his desires had been quenched by the fact that she had already conceived.
In terms of direct Biblical evidence of the perpetual virginity of Mary, St. Jerome and later St. Augustine used Luke 1:34 as evidence of a pledge by Mary to never "know" a man:
And Mary said to the angel: How shall this be done, because I know not man?
The Catholic Encyclopedia explains:
As to Mary, St. Luke (1:34) tells us that she answered the angel announcing the birth of Jesus Christ: "how shall this be done, because I know not man". These words can hardly be understood, unless we assume that Mary had made a vow of virginity; for, when she spoke them, she was betrothed to St. Joseph.
Please see also: The Perpetual Virginity of Mary by Dr. Robert Schihl | EWTN.