Though rail transport had been known through Dutch traders in Dejima, Nagasaki earlier, the impact of model railroads brought by foreigners such as Yevfimy Putyatin and Matthew Calbraith Perry was huge. The British also demonstrated a running steam locomotive in Nagasaki. Saga Domain, a Japanese feudal domain (han), made a working model and even planned to construct a line by themselves. Other bodies such as the Satsuma Domain and the Tokugawa shogunate also reviewed railway construction. But a real line in service did not come into reality before the Meiji Restoration.
Just prior to the fall of the Shogunate, the Tokugawa regime issued a grant to the American diplomat Anton L. C. Portman to construct a line from Yokohama to Edo (soon to be renamed Tokyo). In the second year of the restoration 1869, after considerable diplomatic manoeuvring with the American mission, the new government of Japan decided to build a railway using British techincal advisors. On September 12, 1872, the first railway, between Shimbashi (later Shiodome) and Yokohama (present Sakuragichou) opened. (The date is in Tenpou calendar, October 14 in present Gregorian calendar). Japan relied on the United Kingdom financially and technically.
The reason of rail gauge choice remains uncertain. It could be because 3 ft 6 in (1,067 mm), as opposed to standard gauge of 4 ft 8+1⁄2 in (1,435 mm), was supposed to be cheaper, or because the first British agent, later whose contract was cancelled, ordered iron sleepers of the gauge. Anyway the decision still affects Japanese railways today, as the narrow gauge became the de facto standard.
Some politicians, such as Inoue Masaru, stated all the railway lines should be nationalized. However, the government was financially strained after the Satsuma Rebellion, making the expansion of the railway network terribly slow. Politicians then wanted to allow private companies to build railways. Consequently, Nippon Railway was founded. It was private entity, but strongly affected and constructions done by the government. It expanded railway lines fairly quickly, completing the main line between Ueno and Aomori (present Touhoku Main Line) in 1891. With the success of Nippon Railway, private companies were also founded. Sanyou Railway, Kyuushuu Railway, Hokkaidou Colliery and Railway, Kansai Railway and Nippon Railway were called "major five private railways" at the time. At the same time, the national railway did open its railway lines, including the current Toukaidou Main Line in 1889, but most of its lines were subsidiary to major private lines. In 1892, the Imperial Diet promulgated the Railway Construction Act, which listed 33 railway routes that should be constructed by either the government or private entities.