Nijmegen is also the name of the municipality that comprises the city itself and the villages of Lent, Nijmegen-Oosterhout and Nijmegen-Ressen that lie to the north of the Waal river. Together they form the district of Waalsprong.
Nijmegen is famous for the International Four Days Marches Nijmegen, an annual event starting on the third Tuesday in July, comprising four days of walking (distances ranging from 30 to 50 km a day), and the accompanying festivities, which have been drawing the largest crowds for any Dutch event in the past few years. 
The University of Nijmegen (Katholieke Universiteit Nijmegen) is also located here.
The first mention of Nijmegen in history is in the 0s BC, when the Romans built a military camp on the place where Nijmegen was to appear; the location had great strategic value because of the surrounding hills, which gave (and give) a good view over the Rhine valley.
In 69, when the Batavians, the original inhabitants of the Rhine and Maas valley, revolted, a village called Oppidum Batavorum had formed near the Roman camp. This village was destroyed in the revolt, but when the revolt had ended, the Romans built another, bigger camp. Soon after, another village formed around it.
In the 4th century, Roman power decreased and Nijmegen became part of the Frankish kingdom. In the 8th century, Emperor Charlemagne built a castle in Nijmegen, which marked the start of an era of prosperity for Nijmegen.
Thanks to the Waal river, trade flourished and in 1230, Nijmegen was given city rights by the Holy Roman Emperor. In 1247, the city was ceded to the count of Gelderland as safety for a loan. The loan was never repaid, and Nijmegen has been a part of Gelderland ever since. This did not hamper trade; Nijmegen even became part of the Hanseatic League.
During the Dutch Revolt, trade came to a halt and even though Nijmegen became a part of the Republic of United Provinces in 1585, it remained a border town and had to endure multiple sieges. There were some highlights, though, such as the Treaty of Nijmegen (1678).
In the second half of the 19th century, the fortifications around the city became a major problem; there were too many inhabitants inside the walls, but the fortifications could not be demolished because Nijmegen was deemed as being of vital importance to the defence of the Netherlands. When, however, events in the Franco-Prussian war proved that old-fashioned fortifications were no more of use, this policy was changed and the fortifications were dismantled in 1874.
Through the second half of the 19th century and the first half of the 20th century, Nijmegen grew steadily. The Waal was bridged in 1878 by a rail bridge and in 1936 by a car bridge, in 1923 the University of Nijmegen was founded and in 1927 a channel was dug between the Waal and Maas rivers.
In 1940, the Netherlands were invaded by Germany and Nijmegen was the first city to fall into their hands. In 1944, Nijmegen was heavily bombed by American planes (the pilots thought they were bombing the German city of Kleve), which caused great damage to the city centre. Later in 1944, the city saw heavy fighting during Operation Market Garden.