Secular music and sacred music were the two main genres of Western music during the Middle Ages and Renaissance era. The oldest written examples of secular music are songs with Latin lyrics. However, many secular songs were sung in the vernacular language, unlike the sacred songs that followed the Latin language of the Church, which is not to say there are not secular songs in Latin or not secular songs that are religious in theme.
In the Middle Ages, and even through the Renaissance and the Age of Enlightenment, any music that was not commissioned by the Catholic Church (or, later, a Protestant church) for liturgical use was and still is considered "secular music." Symphony No. 9 (Beethoven) (commonly called "Ode to Joy") and Messiah (Handel) are both examples of secular music because, despite being wholly and innately religious in theme, they were not commissioned by any church or for use in any religion's liturgy. Symphony No. 9 was commissioned by the Philharmonic Society of London for theater performance, not by the Catholic Church, the Church of England, or any other church and not for liturgical use. Likewise, "Messiah (Handel) was commissioned by the Duke of Devonshire to be performed in Dublin theaters for a series of charity concerts, not by the Catholic Church or any other church and not for liturgical use. So, while "secular" today is often taken to mean non-religious in any way, when it refers to music from the Middle Ages through as late as the 19th century, music with a religious theme may be and very often is "secular music" for the simple fact that it was not written on behalf of any commissioning church or for liturgical use, meaning "secular" does not indicate that it is thematically non-religious but that it is non-religious vis-à-vis a religious organization (i.e., the Church) did not commission its creation, sacred music being definitively music commissioned by the Church for liturgical use, for use by the Church in the Church's established rituals, the Church's ceremonies, and the Church's forms of worship, and any and all other music (i.e., music not fitting that strict definition) being secular music, no matter how religiously themed or gloriously worshipful of God it may be. A caveat: while these definitions of sacred music and secular music still hold true today when referring to such music from the past, they tend not to still hold true today for more modern music as any modern song that is themed in religious worship, regardless of if any church commissioned it or uses it in its liturgy, is not considered secular music, like Christian rock is not considered secular music today, but if it were somehow packed up and sent back to the 1500s, it would be considered secular music today because it would have been considered secular music back in the 1500s because of not being commission by the Church for liturgical use but by the artists themselves, or their labels, for their own personal or professional use and so would have come down through history to today as secular music.