The city was founded on the northernmost point of the Hondsrug area. The oldest document referring to Groningen's existence dates from 1040. However, the city already existed long before then: the oldest archaeological traces found are believed to stem from the years 3950–3720 BC, although the first major settlement in Groningen has been traced back to the 3rd century AD.
In the 13th century, when Groningen was an important trade centre, its inhabitants built a city wall to underline its authority. The city had a strong influence on the surrounding lands and made its dialect a common tongue. The most influential period of the city was the end of the 15th century, when the nearby province of Friesland was administered from Groningen. During these years, the Martinitoren was built, which loomed over the city at (then) 127 metres tall, making it the highest building in Europe at the time. The city's independence came to an end when it chose to join forces with the Spanish during the Eighty Years' War in 1594. It later switched sides, joining the Republic of the Seven United Netherlands.
In 1614, the University of Groningen was founded, initially only for religious education. In the same period the city expanded rapidly and a new city wall was built. That same city wall was tested during the Third Anglo-Dutch War in 1672, when the city was attacked fiercely by the bishop of Münster, Bernhard von Galen. The city walls resisted, an event which is celebrated with music and fireworks on 28 August (as "" or "Bommen Berend").
The city did not escape the devastation of World War II. In particular, the main square, Grote Markt, was largely destroyed in April 1945, at the Battle of Groningen. However, the Martinitoren, its church, the Goudkantoor, and the city hall were not damaged. The battle there lasted several days.