The first railway in Norway was Hovedbanen between Oslo and Eidsvoll and opened in 1854. The main purpose of the railway was to freight lumber from Mjøsa to the capital, but also passenger traffic was offered. In the period between the 1860s and the 1880s Norway saw a boom of smaller railways being built, including isolated railways in Central and Western Norway. The predominant gauge at the time was narrow gauge (1067 mm), but some lines were built in standard gauge (1435 mm). The height of the era came in 1877 when Rørosbanen connected Central Norway to the capital. In 1883 the entire main railway network was taken over by NSB, though a number of industrial railways and branch lines continued to be operated by private companies.
The second construction boom of the main railway arose in the 1910s and included the Bergensbane across Finse to Bergen, connecting Eastern and Western Norway. Also a number of other larger projects were built through the 1920s, including a second line, Dovrebanen, to Trondheim. This period also saw the first electrified railways and a steady conversion from narrow gauge to standard gauge. Norway chose to electrify their network at 15 kV 16⅔ Hz AC.
During World War II there was a massive construction by the German Forces as part of creating Festung Norwegen, including large sections of Nordlandsbanen and the completion of Sørlandsbanen. After the war the main effort was to complete Nordlandsbanen (that reached Bodø in 1962) and completing the decision to electrify 50% of the network, a task not completed until 1970. This allowed the retirement of the steam locomotive, being replaced with electric engines like the El 11 and El 13 or the diesel powered Di 3. In 1966 Norway's only rapid transit, Oslo T-bane was opened, but in the same decade the Bergen tramway was closed. In the 1970s and 80s a lot of branch lines were also abandoned.
In 1980 the massive project of connecting the eastern and western railway networks around Oslo was completed with the opening of the Oslo Tunnel and Oslo Central Station. In 1996 NSB was split in the Norwegian Railway Inspectorate, Jernbaneverket and operating company NSB BA. Since the companies have been split into 10 separate companies and corporations. In 1998 the first new line in 36 years was opened when the high-speed railway Gardermobanen was opened to allow travel at 210 km/h between Oslo, Oslo Airport and Eidsvoll. The 1990s also saw the massive introduction of multiple units on passenger trains. In the 2000s the freight segment was deregulated and a number of freight companies have started competing with the NSB partial subsidiary CargoNet.