The line built by the Berlin-Hamburg Railway Company, work starting on 6 May 1844, and was taken into service on 15 December 1846. It was then the longest trunk route in the German states, and ran from Berlin's Hamburg station (from October 1884 from Lehrte station), via Spandau, Neustadt (Dosse), Wittenberge, Ludwigslust, Büchen and along the already existing 15.6-kilometre (9.7 mi) route of the Hamburg-Bergedorf Railway to the Berlin station in Hamburg.
The line ran through the territories of five then independent countries within the German Confederation: the Free and Hanseatic City of Hamburg, two duchies ruled over by the King of Denmark (Holstein and Lauenburg), the Grand Duchy of Mecklenburg-Schwerin and the Kingdom of Prussia. Since Bergedorf was a condominium, jointly owned by the Free Hanseatic City of Lübeck and Hamburg, Lübeck was also affected by its construction.
On 8 November 1841, these countries jointly signed a treaty that specified the route and transit tariffs. A company was established, which obtained the rights to construct and operate the railway in these countries in 1845. The willingness of Hamburg and Mecklenburg to subscribe part of the share capital was a prerequisite for the establishment of the Berlin–Hamburg Railway Company (German: Berlin-Hamburger Eisenbahn-Gesellschaft) and the construction of the line. The first ten percent of the share capital, amounting to a total of eight million thalers, was subscribed in 1844, so that construction could start near Ludwigslust immediately. Up to 10,000 people were employed on the construction at its peak.
The first section to be opened was the 222-kilometre (138 mi) route from Berlin to Boizenburg, which was put into operation on 15 October 1846. The completion of the remaining 45-kilometre (28 mi) section to Bergedorf, on 15 December 1846, completed the line’s construction. Together with the Hamburg–Bergedorf railway, which had opened for passenger on 16 May 1842 and for freight on 28 December 1842, the total Berlin–Hamburg line was put into operation on 15 December 1846. The Hamburg-Bergedorf Railway Company merged with the Berlin–Hamburg Railway Company. In Hamburg, the Berlin station (Berliner Bahnhof) was opened on the site of the present Deichtorhallen. It consisted of a reception building and an open timber hall with four tracks.
The first managing director from 1850 was Ernst Georg Friedrich Neuhaus, who filled this office with great dedication until his death on 4 December 1876.