Hafnir is a village in southwestern Iceland.
It is situated in the Reykjanes peninsula and has 109 inhabitants (as of 2011).
In 1994 the inhabitants of Hafnir, Njarðvík and Keflavík agreed to form a municipality called Reykjanesbær with a population of 20,416 (July 2022).
A cabin in Hafnir abandoned between 770 and 880 provides the earliest known archaeological evidence of settlement in Iceland.
In 1881, the American ship Jamestown ran aground off Hafnir with no one aboard. Its cargo of timber was salvaged and sold off. The ship’s anchor is on display outside the village church.