1590s, "of the highest rank" (originally in literature), from classic + -al (1). Classical music (1836) was defined originally against romantic music.
But already by 1880s it was acknowledged the term had a double sense: Music that had withstood the test of time, as well as music of a style contrasted to "romantic." Later (early 20c.) it was contrasted to jazz (in this sense more often with reference to the orchestras than to the music itself). Still later in contrast to popular music generally (mid-20c.).