Writer and television producer Alistair Moffat has been chosen as the Rector at the University of St Andrews.
Mr Moffat, 61, a former director of the Edinburgh Fringe, was one of five names in the election for the post.
The others were Tory politician Michael Forsyth, socialist politician Colin Fox, broadcaster Abeer Macintyre and ex-footballer Pat Nevin.
The Rector acts on behalf of the students and chairs the university court, its supreme governing body.
Scotland's ancient universities - St Andrews, Edinburgh, Glasgow and Aberdeen - have a rector, as does Dundee.
The previous rector of St Andrews was Kevin Dunion, the Scottish information commissioner.
Peter Pan author J M Barrie, Jungle Book creator Rudyard Kipling and comedian John Cleese have also held the post.
Almost half of the electorate turned out to vote in the latest poll, which was conducted using electronic voting.
Mr Moffat, who was a former director of programmes at Scottish Television, graduated from St Andrews in 1972.
He said: "When 600 years ago the candles of enlightenment were first lit in St Andrews, they shone light into some dark corners.
"Now cold winds are blowing and storms gathering out there and the candles are flickering and growing dim.
"But what is wonderful about St Andrews are its students, and with their energy and commitment, St Andrews will burn brightly again without a doubt."
Students' Association president Patrick O'Hare said: "This election has been a triumph for student democracy - a turnout of 49% is a remarkable statistic and demonstrates once again how much the students of St Andrews value the important position of Rector and the place of student activism."