Having attended the Scottish Parliament on Saturday to mark its 20th anniversary celebrations, the Queen joined the service for around an hour, before speaking with some members of the congregation inside.
Reverend Neil Gardner walked with the Queen as she departed the Kirk just after midday.
The visit to Scotland is part of a week-long programme of engagements, meeting Scots from across the country.
Speaking at Holyrood on Saturday, the Queen, accompanied by Prince Charles - who is known in Scotland as the Duke of Rothesay - said that she had “watched Scotland grow and prosper” over the last two decades.
Current and former MSPs were present for the speech, along with some of the Scots who were born on July 1 1999 - the day the Scottish Parliament was officially opened.
In her speech, the Queen said: “As we look to the future, it is my sincere hope that this Parliament, and all those who come to serve in it, will use the power of this chamber to celebrate those invisible pillars of our communities, and follow their example by working tirelessly to improve people’s lives, and strengthen the bonds of friendship and partnership both at home and abroad.”