Queen Elizabeth II has thanked the public for the "touching messages of great kindness" she has received on the day she became Britain's longest-reigning monarch.

Delivering a rare speech during her opening of the Scottish Borders Railway, the longest new rail route to be built in the UK for more than 100 years, the Queen spoke of her delight at opening the line and of her gratitude for the messages of support she has received on the day she surpasses the record held by her great-great grandmother, Queen Victoria.

Queen Elizabeth II longest reign
Queen Elizabeth II opens Newtongrange Station after arriving on the steam locomotive the Union of South Africa Jeff J Mitchell/Getty Images

"The Duke and Edinburgh and I are delighted to be back in the Borders today and especially to have arrived by train. It has been wonderful to witness the excitement, which the return of the railway has brought here. The Borders Railway brings so much promise for sharing and invigorating this most beautiful countryside as a place to work, live and enjoy," she said.

"Prince Philip and I are very grateful for the warmth of your welcome on this occasion. Many, including you First Minister, have also kindly noted another significance attaching to today, although it is not one to which I have ever aspired.

"Inevitably a long life can pass by many milestones. My own is no exception. But I thank you all and the many others at home and overseas for your touching messages of great kindness," added Her Majesty.

Queen Elizabeth II: The life and legacy of Britain's longest reigning monarch IBTimes UK

Earlier in the day crowds cheered and waved flags as the monarch and husband Prince Philip were met by First Minister Nicola Sturgeon at Edinburgh Waverley station. The Queen smiled broadly as she boarded the train drawn by the steam locomotive Union of South Africa.

At about 5.30pm on 9 September, the Queen, who now aged 89, will surpass the 63 years, seven months, two days, 16 hours and 23 minutes that her great-great-grandmother Queen Victoria spent on the throne.

Initially, the Queen did not intend to mark the event publicly but she bowed to public pressure and undertook an official engagement in Scotland, where she traditionally spends her summer holiday.