The Inverness and Perth Junction Railway was built to link the Inverness and Aberdeen Junction Railway at Forres and Perth and Dunkeld Railway, ultimately absorbing the latter.
The Act of Parliament was passed on 22 July 1861, with the line being opened between Dunkeld and Pitlochry on 1 June 1863, between Forres and Aviemore on 3 August 1863 and the final section to Aviemore and Pitlochry on 9 September 1863.
It combined with the Inverness and Aberdeen Junction Railway to form the Highland Railway on 1 February 1865. The line became part of the LMS in 1923.
The Aberfeldy Branch was authorised under the original Act of Parliament, being opened on 3 July 1865, just after the formation of the Highland Railway.
The Aberfeldy Branch was closed on 3 May 1965, just short of its centenary. The line between Forres and Aviemore closed on 18 October 1965.
Following closure of the section north of Aviemore, there were moves to re-open the line between Aviemore and Grantown-on-Spey West. The Strathspey Railway has progressively reopened the line north from Aviemore, with the current terminus at Broomhill. They hope to reach Grantown-on-Spey within the next few years; however, the impressive 1897 station at Grantown-on-Spey (West) was demolished in the early 1980s and a new terminus will be built on a greenfield site 3/4 track-mile to the north.
The line remains open as of August 2016 as part of the Highland Main Line between Dunkeld and Birnam and Aviemore operated by Abellio ScotRail, and as part of the restored Strathspey Railway between Aviemore and Broomhill.