Track-laying has been completed for the new link between the Borders and Edinburgh.
The operation began at Shawfair station, south-east of the capital, in October.
Engineers have used a specialist rail installation machine to lay the track along the 30-mile route to Tweedbank.
Transport Minister Keith Brown said: "It is a huge honour to put the final piece of track in place and travel on the first train to run into the Borders in almost half a century.
"The reopening of this line offers a once in a generation opportunity to deliver a major economic and social boost for the communities it will serve.
"In just a few short months, trains will be carrying passengers to employment, social and study opportunities, as well as bringing visitors and investors to the communities all along the route."
He added that there would be "few, if any" railway journeys in Europe with such outstanding scenery.
The Borders Railway: In Figures
Network Rail's project director, Hugh Wark, added: "The completion of rail installation is a major milestone for the project and keeps the line on-track to open for passengers in September.
"While we still have a significant amount of infrastructure to complete along the route - from installing signalling to completing the stations - we're confident that this much-anticipated addition to Scotland's railway will be delivered on schedule."
The line is due to open to passenger trains on 6 September.
The Campaign for Borders Rail has welcomed a redesign of the Tweedbank station to accommodate tourist charter trains.
It predicts tourist and leisure travel will be a key aspect of the success of the new railway.
Simon Walton, who chairs the group, said its research and lobbying and the intervention of MSP Claudia Beamish were instrumental in seeing Tweedbank station extended to cope with 12-coach charter trains.
"We were delighted that the minister had the vision to see the massive potential of tourism," he added.
He said he looked forward to a study of "further enhancements" including a turntable to turn steam engines at Tweedbank and hoped to see the line extended at least as far as Hawick.
Do you agree with local MP Michael Moore, who said the opening of the Borders Railway could be an "Olympic moment" for the region? Or do you have concerns that the costs of a railway 30 miles long can be justified? Let us know your views by emailing us on selkirk.news@bbc.co.uk or tweeting @BBCSouthScot.
Follow the story throughout the day on our live page.
The longest domestic railway to be built in the UK in more than 100 years has reached a significant milestone.