Olympic torch relay: Edinburgh crowds greet flame
The Olympic cauldron has been lit at Edinburgh Castle at the end of a day which saw large crowds turn out to watch the flame.
Thousands of people thronged the streets as the torch relay made its way through the city, pausing on The Mound before being carried up the Royal Mile.
Earlier the flame was carried on St Andrews' West Sands Beach, recreating the opening scene of Chariots of Fire.
On its last full day in Scotland, the relay visited a number of other landmarks including the Falkirk Wheel, the Forth Road Bridge and the Old Course at St Andrews.
The flame was carried into Edinburgh Castle by Lesley Forrest, 55, who received a kidney transplant in 1996 and a year later started competing in the British Transplant Games with the Scotland team. She became a multiple medallist at both the British and World Transplant Games.
Scottish Secretary Michael Moore, who was at the castle to watch the cauldron being lit, said the public had given the relay an impressive reception throughout Scotland since its arrival at Stranraer on 7 June.
"It's been very staggering how many people turned out in rain and sun the length and breadth of the country. We have seen people embracing the torch and the Olympics and being part of it," he told the BBC.
The first of the day's 115 torchbearers in the centre of St Andrews was record-breaking Scottish long-distance cyclist Mark Beaumont.
Perthshire-born Beaumont cycled round the world between August 2007 and February 2008, travelling 18,296 miles in 194 days through 20 countries.
On Wednesday morning, he ran from the university - where the Duke and Duchess of Cambridge once studied - through the city, and later took the torch on the Forth Road Bridge.
London 2012 Olympic torch relay
Search maps, check street routes and join in 70 days of live coverage in video, stories and pictures
At the famous golf course, the torch was carried by Louise Martin, chair of Sport Scotland, over a landmark for golf fans, the stone Swilcan Bridge.
It was originally built for shepherds but now spans the creek between the first and 18th fairways.
She said after carrying the torch: "It's quite surreal. I can't believe I've actually done it. It's churning inside, just the pleasure and what it meant to me."
Joseph Forrester, 13, led a group of children from Madras College across West Sands Beach beach in St Andrews to recreate the scene in the film Chariots of Fire - in which the beach doubles as Broadstairs in Kent.
After carrying the torch, Joseph, a member of Fife Athletics Club, said: "I was nervous because there were loads of people there, but I'm all right now.
"I'd love to compete in the Olympics one day."
Wednesday's route also took in Kinross, Alloa, Dunblane, Stirling, Falkirk and Dunfermline on the way to Edinburgh.
Torchbearers included John Legend - an American singer-songwriter who has won nine Grammys - and Scottish former ice dancer John Kerr.
The torch visited Stirling Castle, a symbol of Scottish independence with a long and turbulent history associated with great figures from Scotland's past such as Mary Queen of Scots and Sir William Wallace, who was the Guardian of Scotland.
The flame was carried up the cobbled street to the castle by Paul McIntyre, who has Becker Muscular Dystrophy.
It was carried in Dunfermline by Andrew Slack, 22, from Linlithgow, who has severe learning difficulties as well as some physical and health problems.
He is a member of the No Limits Sports Club for children and young adults with special needs and won individual gold and team bronze in boccia at the Special Olympics in Leicester in 2009.
A total of 8,000 people are carrying the flame during its 8,000 mile, 70-day journey to the opening ceremony of the Olympic Games in London on 27 July.