In February 1898, the Scottish locomotive builderNeilson, Reid and Company had completed an order for twelve 4-4-0 locomotives for the Great North of Scotland Railway ; these comprised GNSR class T. In October that year, William Pickersgill, the GNSR Locomotive Superintendent, requested authority to purchase a further twelve. Neilsons offered to build between ten and twenty further locomotives of the class T design. The GNSR Board of Directors granted permission for ten locomotives of a slightly modified design incorporating a side-window cab, and Neilson, Reid & Co. were awarded the contract that November at a price of £2975 each. Delivery commenced in October 1899, but by the time that the first five locomotives had been received by the GNSR, they found that a downturn in traffic meant that not only were the remaining five not required, but that they would also be unable to pay for them. Accordingly, the GNSR requested that Neilsons should find an alternative buyer, and to obtain the best possible price. They were duly sold to the South Eastern and Chatham Railway for £3300 each, where they became that company's class G. An offer from the SECR to purchase the first five as well, but at £3325 each, was turned down by the GNSR. A further eight locomotives to the same design as the 1899 batch were built by the GNSR at their Inverurie Works, Aberdeenshire, in 1909–10 and 1913–15. Once again, Pickersgill's recommended quantities were reduced: he had requested ten in 1903, and eight in 1911.
Class F
The class F locomotives were the only ones to be named by the GNSR, all other classes being numbered only. The class originally comprised eight locomotives, six built by the North British Locomotive Company in Glasgow in 1920, the remaining two by GNSR at Inverurie Works in 1921.
The five locomotives ordered in 1898 that the GNSR was unable to pay for were offered for sale by Neilsons, with the authority of the GNSR. On 11 October 1899, Neilsons contacted the South Eastern and Chatham Railway, which had recently placed a locomotive order with them. The SECR was an organisation which had been formed on 1 January 1899, and which was short of express passenger locomotives for the former London, Chatham and Dover Railway routes, which had a weight limit. The SECR quickly accepted the offer, paying £3200 each for them, whereas Neilsons would have charged the GNSR £2975 each; in December, the cost to the SECR was increased by a further £57 per engine and tender after Harry Wainwright, the SECR Locomotive Superintendent, requested modifications including the fitting of vacuum brake equipment. The price difference was split between Neilsons and the GNSR, the latter receiving £1025. On the SECR they were assigned Class G, and entered service during January and February 1900, numbered 676–680. They passed to the Southern Railway at the 1923 Grouping, and, except for no. 678, were given SR numbers A676–A680. They were withdrawn from service between 1924 and 1927.
All 21 GNSR locomotives passed to the London and North Eastern Railway in 1923. The LNER classed them all as D40 irrespective of whether they were fitted with superheaters or not. The LNER initially renumbered them by adding 6800 to their GNSR number. In 1946 they completely renumbered all their locomotives and the D40 class became 2260–2261, 2265–2272, 2262–2264 and 2273–2280. The first locomotive was withdrawn in 1947.
Eighteen of the 21 locomotives passed into British Railways ownership in 1948. BR renumbered them by adding 60000 to their 1946 LNER number. The last locomotive of the D40 class was 62277 Gordon Highlander and it was withdrawn in 1958 from Kittybrewster Depot, Aberdeen.
Preservation
Number 62277 was preserved and renumbered as 49 as an example of the superheated version. GNSR No. 49, Gordon Highlander was also numbered as LNER No. 6849 at the Grouping, LNER No. 2277 in 1946 and BR No. 62277 on nationalisation. At withdrawal, it was the only survivor of the class still in service. Restored to GNSR green in 1958, though it never carried green livery in GNSR service since it originally appeared in Heywood's lined black, it was given an occasional airing on specials before retirement to the Glasgow Transport Museum. It has been moved to the Scottish Railway Museum at Bo'ness rather than the new waterfront Glasgow Transport Museum. On 13 June 1964Gordon Highlander was used on the "Solway Ranger" railtour of Cumbria, on the section between and.