The ground here was in use long before any town. Painted shelters at Laas Geel, on the outskirts, date to the Neolithic. French archaeologists surveyed them in late 2002, though the people living nearby had known about the paintings for centuries.
Hargeisa began as a water stop for herders and caravans moving between the coast and the interior. The modern town dates from about 1860, when Sheikh Madar Shirwa, a Qadiriyya teacher from Berbera, founded a religious commune here on the advice of a scholar in Harar. The name is usually read as "Little Harar", after the city where he studied.
Madar did something unusual for a pastoral society: he settled people. Sorghum fields fed the commune, stone houses went up, and the mullahs looked after the sick and the old. A British soldier and explorer who travelled the region in the late 1800s found the town full of blind and lame people under the sheikh's care, with some four hundred workers scaring birds off the crops.
The British set up a protectorate in 1888 with Berbera as its capital. Hargeisa took over later and was given capital status in 1941, after Italy had invaded in 1940 and been pushed out within months. In 1945 the colonial government arrested several religious leaders in the town. A crowd of thousands marched to free them, and troops fired on it.
Independence from Britain came on 26 June 1960, and days later the protectorate merged with Italy's old colony to form the Somali Republic. Hargeisa then became a provincial capital. It still got a provincial museum and an upgraded airport.
On 31 May 1988 the Somali National Movement attacked the city before dawn and held most of it by the next day. Siad Barre's government answered with shelling and aerial bombardment aimed at Isaaq civilians. Up to 90% of Hargeisa was destroyed.
Rebuilding began after the central government collapsed and Somaliland declared independence in 1991. It was paid for largely by local businesspeople and by Somalis abroad sending money home through Somali-owned transfer companies. Most wrecked buildings have been replaced, and single-storey downtown blocks are giving way to high-rises. The population grew from around 560,000 in 2005 to an estimated 1.1 million in 2023.