the hamburg–lübeck railway is one of the most important mainline railways of the german states of schleswig-holstein and hamburg. it connects the two hanseatic cities of hamburg and lübeck, and is part of the line to denmark. the line was opened in 1865.