Few British lawyers have combined a stellar professional career as advocate, law officer and judge with a global academic reputation as scholar and historian. One such was Alan Rodger, who has died of a brain tumour aged 66. He was successively lord advocate, lord justice general of Scotland and lord president of the court of session, lord of appeal in ordinary and justice of the supreme court. But he was also an Oxford don, elected to fellowship of the British Academy and the Royal Society of Edinburgh.

He was disarmingly modest about his own achievements and had a sense of the ridiculous. But behind his mischievous sense of humour was a strong, almost Calvinist sense of morality: our primary duty is hard work. This was reflected in his dedication to public service.

Alan was born and brought up in Glasgow which, with his holiday home on the coast of Fife, continued to be the focus of his close family life, with his sister, brother and two devoted nephews, all of whom survive him. Although much of his later professional life was centred in Edinburgh, he always thought of himself as a Glaswegian and loved to poke fun at the pretensions of the capital. Alan's father, Thomas Rodger, was a professor of psychological medicine and Alan developed an interest in medicine and medical ethics which came through in his judgments and lectures. After school and university in Glasgow, he went to Balliol College, Oxford, to write a doctoral thesis in Roman law.

There, Alan was influenced by his supervisor, Professor David Daube, beginning, as he said, with skirmishes across the fireplace in All Souls. His thesis, published as Owners and Neighbours in Roman Law (1972), already showed the abiding characteristics of all his writing: precise analysis of language, coupled with a keen eye for the working of legal rules in ancient and modern society. In several of his judgments, he used the principles of Roman law to point the way to the solution of contemporary problems. He was one of the few people who could converse with other scholars in Latin.

In 1970 he was elected to a fellowship at New College, with special responsibility for teaching Roman law. But, although a chair would have been his almost for the asking, he felt that an academic career would not satisfy him and, to general surprise, he threw up his fellowship after two years and set about training for the Scots bar. Nevertheless, he maintained his Oxford links, returning even as a law lord to help with the teaching of Roman law. After training with a firm of solicitors specialising in family and personal injury litigation, where he could learn the nuts and bolts of court procedure, he was admitted to the faculty of advocates in 1974. Within two years, he was elected by his colleagues to the office of clerk of faculty. After a very successful career in junior practice, he took silk in 1985. He then accepted (at considerable financial sacrifice) appointment as one of the counsel responsible for prosecuting serious crime in the high court. He was a skilled and steely prosecutor who enjoyed the cut and thrust of criminal advocacy.

He returned briefly to civil practice in 1988, but the following year he was appointed solicitor general for Scotland, which took him into the heart of Whitehall. He provided (often at very short notice) authoritative opinions on issues of international and public law, and his advice was sought and valued by ministers. In 1992 he was appointed lord advocate, with a seat in the Lords. He was closely involved in directing the investigation into the Lockerbie bombing and appeared for the British government in the international court of justice where Libya claimed the right to try the suspects in its own courts. In the Lords, Alan was an adroit frontbencher with responsibility for steering legislation, not only on Scottish issues.

In 1995 he began his judicial career. His judgments were marked by great learning, luminous clarity and human understanding. "Murder is constituted by any wilful act causing the destruction of life, by which the perpetrator either wickedly intends to kill or displays wicked recklessness as to whether the victim lives or dies." Gay men should not have to forgo "the small tokens and gestures of affection which are taken for granted between men and women". And his dissents could be caustic: "Until now, judges, lawyers and law students have had to try to work out what parliament meant ... Now they must also try to work out what the supreme court means by these words. It is a new and intriguing mystery."

Throughout his intense public life, he continued to write on erudite points of Roman law and to explore the side alleys of legal history, often doing the groundwork on aeroplanes when he could not work on confidential papers. What, for example, was "a very good reason for buying a slave woman"? Why did Lord Macmillan change his speech in Donoghue v Stevenson (the case of the snail in the ginger beer bottle which revolutionised the law of negligence)? Who indeed was Mrs Donoghue and what happened to her? Why did Scottish advocates go to Germany in the 19th century? Rarely declining an invitation to speak to a society of students or young lawyers, he also dealt with many aspects of modern legal practice, frequently challenging conventional wisdom such as the notion that litigation is always a bad thing.

Apart from the law, Alan's chief interest in life was other people. He had a deep commitment to his family, his friends and their children and, in his professional and academic life, to his colleagues, students and the often- forgotten support staff. He never married, but he became a father figure to many younger people. Their concerns, problems, interests, excitements were his too. Life with him could be fun, and it is typical that his last outing before his illness took hold was with a former pupil, now a judge, to the races at Musselburgh. Alan was admired by all those who had the good fortune to know him. And we shall miss those long talks, deep into the night, when public absurdities were merrily dismantled and private worries resolved with generous human understanding.

•Alan Ferguson Rodger, lawyer, born 18 September 1944; died 26 June 2011