The origins of the postgraduate degree, specifically the doctorate, dates back to the ijazat attadris wa 'l-ifttd
("license to teach and issue legal opinions") in the medieval Islamic legal education system
Postgraduate education (Wikipedia)
faqih (meaning "master of law"), mufti (meaning "professor of legal opinions") and mudarris (meaning "teacher"),
which were later translated into Latin as magister, professor and doctor respectively