St Andrews has been rated the third best university in the UK by an annual guide.

The Fife institution came top of all Scottish universities in the Complete University Guide 2018.

Across the UK, only Oxford and Cambridge came higher than St Andrews, which secured its highest place on the table.

The guide is based on ten measures including quality of research, prospects for graduates and student infrastructure.

A total of 129 institutions were listed in this year's edition.

As a nation, Scotland outperformed the other UK countries in three of the key measures used to rank universities.

The mean scores for Scottish universities in entry standards, good honours and graduate prospects are all higher than those recorded in England, Northern Ireland and Wales.

Professor Sally Mapstone, principal of St Andrews, said:"This all-time high is a great endorsement of what St Andrews stands for.

"Our values are those of a small, Scottish and highly international university. We are outward looking, inclusive and focused on excellence.

"We see teaching quality and research excellence as commensurate and we provide them in an environment that is beautiful, friendly and enriching."

She added: "That Scottish universities have done so well in three of the key measures here is notable.

"Brexit and its consequences notwithstanding, Scottish universities will strive to continue to outperform and we look for meaningful support to enable us to do so."

Dundee University also performed well, rising six spots to 29th in the UK and featuring in the top ten for six of the subjects it teaches in this year's guide.

Professor Sir Pete Downes, university principal, said: "There are many factors driving our rise in the Complete University Guide, including the fact we are one of the most research intensive universities of comparable size in the UK, our internationally renowned student experience and our excellent record in employability.

"This is a ranking driven by issues of concern for students and those considering which university to go to so it is especially pleasing that we have recorded another strong showing in it.

"I am also delighted that six of the subjects we offer have been recognised as being among the best in the UK."