A bachelor's degree is named after a knight's apprentice squire
Medieval Latin used baccalaureus for a squire serving a knight, and universities borrowed it for students halfway to mastery. 'Graduate' comes from gradus, a step, because each degree was just one rung toward joining a teachers' guild. Master and doctor originally meant exactly the same thing.
The doctorate began as a licence to teach, the licentia docendi, from Latin doceo, I teach. The church originally controlled it, charging a fee and requiring an oath. The Third Lateran Council of 1179 opened it to all able candidates, largely free of charge, and in 1231 the Pope let the University of Paris grant a licence valid everywhere. Earning it was like a craft apprenticeship: seven years of study before admission to the guild of Masters of Arts, the same term other trades demanded.
A typical path ran through three or four years on the trivium of grammar, rhetoric and logic and the quadrivium of arithmetic, geometry, astronomy and music, followed by exams set by one's master. Disputations then earned the Master of Arts, which opened the higher faculties of law, medicine and theology. Because arts study was the prerequisite for those faculties, whose graduates were called doctors, 'doctor' drifted above 'master'. Bologna, often called Europe's oldest university, granted the first doctorates in civil law in the late 12th century. The research PhD in its present form grew out of 18th and 19th-century German universities, and England did not introduce it until after 1900.
Origins are disputed. Historian George Makdisi proposed that the ijazah of 9th-century Islamic madrasas inspired the European doctorate; Toby Huff and others reject this. Devin Stewart notes a key difference: an ijazah was granted by an individual teacher, whereas a university degree came from a corporate body.
Old customs survive. France still calls its school-leaving exam the baccalaureat and its first university degree a licence. The Archbishop of Canterbury awards 'Lambeth degrees' under powers inherited from the Pope by the Peter's Pence Act 1533. British graduates still write 'Oxon' and 'Cantab' after their names, partly to set the Oxbridge MA, historically not earned by further study, apart from ordinary ones.
Source: Academic degree