Dunbar Railway Station (Gael: Dùn Bàrr) lies on the East Coast Main Line, a quarter-mile (0.5 km) southeast of the town centre. It opened in 1846 with the North British Railway's line linking Edinburgh and Berwick-upon-Tweed although, today, many East Coast Main Line services do not stop here. The track geometry is unusual. One of the original two platforms was demolished, leaving a single platform on a loop line that lies separate from the pair of through-lines used by non-stop services. This means that both north and south-bound services are diverted onto the loop line if they stop here. The original T-plan station buildings are still used, although much modified.
Dunbar Railway Station is now operated by ScotRail and is fully-staffed. It saw a significant increase in usage between 2010 and 2015; from 318,976 to 453,000 passengers per annum. Dunbar is preceded by Berwick-upon-Tweed Railway Station, 15 miles (24 km) to the east southeast, and followed by Drem, 10½ miles (17 km) west, although the next stop for most services is Edinburgh Waverley, 26 miles (42 km) to the west.