The site was already known by sailors in the 15th century. Petroglyphs from that time are carved into the rock at the Hauensuoli (Swedish: Gäddtarmen, English: Pike's Gut) island.
Hanko has a long history of wars and battles. The Battle of Gangut between Swedish and Russian navies was fought in 1714 in the archipelago north of the peninsula. The battle was the first-ever victory of the Russian regular fleet.
The fortification works on the Hanko Peninsula had already been started by the end of the 18th century, when the Swedish constructed three separate forts on the outlying islands. The forts were taken over by Russia in 1809, and were later bombarded by the Royal Navy during the Crimean War and they were eventually blown up during the hostilities by their own defenders.
The city was founded in 1874, soon after the Hanko-Hyvinkää railway was inaugurated in 1872. The Imperial Charter for the city was granted by Tsar Alexander II.
Hanko was the port of choice for emigrants leaving Finland for a new life in North America in the late 19th and early 20th centuries. A memorial statue, showing birds in flight, commemorates this.
In the late 19th century, while Finland was still a Grand Duchy under Russia, Hanko was a popular spa resort for the Russian nobility. Some of the buildings from that period survive, notably the Hanko Casino (which is not a gambling establishment, but a former banquet hall of the spa). It is nowadays a restaurant.
Field Marshal C. G. Mannerheim owned a café, Neljän Tuulen Tupa ("The House of the Four Winds") which still is very popular among tourists and residents alike.
The Bengtskär lighthouse is the highest one (52 m/171 ft) in the Nordic countries. It is situated 25 km (16 mi) southwest of Hanko. It was built in 1906 and it is the first lighthouse museum in Finland.
In the Moscow Peace Treaty that ended the Winter War on March 13, 1940, Hanko was leased to the Soviet Union as a