People arrived here as the ice melted, about 10,000 years ago. By the 9th and 10th centuries North Jæren, the flat country around today's city, was a centre of power, and the Battle of Hafrsfjord around 872 is tied to the founding of the Norwegian kingdom. The name comes from Old Norse Stafangr, most likely first given to the bay that is now Vågen. The harbour was the city's first site.
The city began as a church town. The cathedral was begun by Bishop Reinald, possibly an Englishman from Winchester. Work ended about 1125, a date the city still treats as its birth year. A great fire in 1272 left much of the town and the cathedral in ruins, and the church has Gothic additions from later.
The Reformation hit hard. In 1537 the king confiscated the estates of the bishop and the monastery, and in the early 1600s the bishopric moved to the new town of Kristiansand. What revived it, in the 19th century, was herring.
Herring led to canning, and canning built the Stavanger you walk through. Shipyards and canneries employed the town until about 1950, and the Canning Museum in Old Stavanger sits in a cannery that ran from 1916 to 1958. Much of the wooden city dates from the mid 1800s to the mid 1900s. The centre still has a small-town feel, with an unusually high number of detached houses.
The war reached Stavanger on the morning of 9 April 1940. Sola airport was the first target in the area and fell after a parachute assault, only the second in history. German troops walked into the city around 12:30 without a fight. Occupation lasted five years, and Rogaland had 180 German minefields holding 480,000 mines. Concrete defences still sit in the dunes at Sola.
The 1960s were lean: Stavanger was one of the poorest cities in Norway. Then the Ekofisk field was found in 1969, and the state oil company, Statoil, now Equinor, was founded in 1972 and placed its headquarters here. Norwegian Contractors cast the concrete Condeep platforms for Gullfaks and Troll A at Stavanger. The poorest city became the richest, and the centre of the oil industry.
Stavanger shared the title of European Capital of Culture with Liverpool in 2008. On 1 January 2020 the neighbouring municipalities of Finnøy and Rennesøy merged with it.