Hafnarfjörður takes its name (meaning harbor fjord) from the area's excellent natural harbour. The town is first named in the medieval "Book of Settlements", and the earliest reports of voyages to Hafnarfjörður date from the end of the 14th century. Englishmen began trading in Hafnarfjörður in the 15th century, but German merchants followed in their wake and eventually drove the English out. The first Lutheran church in Iceland was raised at Háigrandi, opposite Óseyri, just outside of the small boat harbor in 1533. After that, the Hanseatic traders prevailed in town until 1602, based at Hvaleyri. At this point, the Danish monarchy established a Danish trade monopoly in Iceland which lasted until late in the 18th century. During this period, Hafnarfjörður was the nation's busiest trade centre.
In 1793, Bjarni Sívertsen settled here and became influential in local business and international trade, setting up a major commercial fishing operation. His enterprise and initiative signaled the start of impressive commerce in the town. Ever since, he has been called "the father of Hafnarfjörður" and nicknamed "Sir Bjarni." Around 1870, dramatic changes took place in Icelandic fishing. Residents followed the growing trend in Iceland of using decked boats rather than row-boats. This led to even more employment and rapid growth, and Hafnarfjörður attained official municipal status in 1908. The first mayor was Páll Einarsson, who later became the mayor of Reykjavík. The first road between Reykjavík and Hafnarfjörður was finished in 1898. The first hydrological power plant in Iceland was built in Hafnarfjörður in 1904.
The Coot, Iceland's first trawler operated from Hafnarfjörður between 1905 and 1908. Its boiler stands by the roundabout on the junction of Reykjavíkurvegur, Strandgata and Vesturgata. A harbor for large commercial ships was raised in 1912, and the first car arrived in 1913.