Scotland's universities have been ranked from best to worst in a new league table for 2021.

The Times and The Sunday Times Good University Guide 2022 has released the new table for each institution as thousands of students head back to lectures.

St Andrews came first in the UK, beating Oxford and Cambridge - something which no other university has ever achieved.

The Fife uni came top out of 135 institutions, scoring the best marks on student satisfaction despite moving to online teaching during the pandemic.

Newly published data for 2022 shows how each university was ranked on teaching quality, student experience, graduate prospects and competition rate.

The University of Glasgow came in at second place in Scotland

The University of Glasgow came in at second place in Scotland and is placed 12th in the national league table, its highest ever ranking.

It was awarded Scottish University of the Year by The Time due to student experience and teaching quality as it undergoes a billion-pound campus overhaul.

The University of Edinburgh came in at third place, while Strathclyde University ranked fourth in Scotland.

In the UK league table, Scottish universities held their own against elite institutions in England, with five appearing in the top 20.

Scotland's university league table 2022

1. University of St Andrews

2. University of Glasgow

3. University of Edinburgh

4. University of Strathclyde

5. University of Aberdeen

6. Heriot-Watt University

7. University of Dundee

8. University of Stirling

9. Edinburgh Napier University

10. Glasgow Caledonian University

11. Robert Gordon University

12. Queen Margaret University

13. Abertay University

14. University of the West of Scotland

University of Edinburgh came in at third place

Top 20 universities in UK 2022

1. University of St Andrews

2. University of Oxford

3. University of Cambridge

4. Imperial College London

5. London School of Economics

6. Durham University

7. University College of London

8. University of Warwick

9. University of Bath

10. Loughborough University

11. Lancaster University

12. University of Glasgow

13. University of Edinburgh

14. University of Bristol

15. University of Leeds

16. University of Southampton

17. University of Strathclyde

18. King's College London

19. University of York

20. University of Aberdeen

University of Strathclyde came fourth in Scotland and 17 in the UK

Alastair McCall, editor of The Times and The Sunday Times Good University Guide, said: "St Andrews’ achievement in topping our institutional table should not be underestimated.

"Never before has any university other than Cambridge and Oxford finished top – or any other – domestic ranking of universities."

"It is no fluke. The university has been closing in on the Oxbridge duopoly for several years, buoyed by outstanding levels of student satisfaction which have peaked during the past year of pandemic disruption on campus.

"The lead St Andrews now has over other universities in this key area of university performance is remarkable.

Get the latest headlines sent straight to your inbox with our newsletter

Did you know you can keep up to date with the latest news by signing up to our daily newsletter?

We send a morning and lunchtime newsletter covering the latest headlines every day.

We also send coronavirus updates at 5pm on weekdays, and a round up of the week's must-read stories on Sunday afternoons.

Signing up is simple, easy and free.

You can pop your email address into the sign up box above, hit Subscribe and we'll do the rest.

Alternatively, you can sign up and check out the rest of our newsletters here.

"Its wider contribution as a centre of teaching and outstanding research marks it out as a global player in the international higher education marketplace.

"Strange to say for an institution that has been around for 600 years, but topping our UK rankings for the first time truly marks St Andrews “arrival” as a serious challenger to Oxford and Cambridge.”

What do you think of the university league table? Let us know in the comments below.

Don't miss the latest news from around Scotland and beyond - Sign up to our daily newsletter here.