For much of its history Gao was an important commercial centre involved in the trans-Saharan trade. In the 9th century external Arabic writers described Gao as an important regional power and by the end of the 10th century, the local ruler was said to be a Muslim. Towards the end of the 13th century Gao became part of the Mali Empire, but in first half of the 15th century the town regained its independence and with the conquests of Sonni Ali (ruled 1464–1492) it became the capital of the Songhai Empire. The Empire collapsed after the Moroccan invasion in 1591 and the invaders chose to make Timbuktu their capital. By the time of Heinrich Barth's visit in 1854, Gao had declined to become an impoverished village with 300 huts constructed from matting. In 2009, the urban commune had a population of 86,633.
On 31 March 2012, Gao was captured from Malian government forces by National Movement for the Liberation of Azawad (MNLA) and Ansar Dine rebels. After the additional captures of Kidal and Timbuktu, on 6 April, the MNLA declared the region independent of Mali as the nation of Azawad and named Gao its capital. The MNLA lost control to Islamist militias after the Battle of Gao on 26 and 27 June 2012. On 26 January 2013, the city was recaptured by French military forces as part of Opération Serval.
Gao is located on the eastern bank of the Niger River at the junction with the Tilemsi Valley. The sprawling town is the largest in eastern Mali. It is connected to the capital, Bamako at the western end of Mali, by 1200 km (750 mi) of paved road. In 2006, the Wabaria bridge was inaugurated to replace the ferry service across the Niger. The bridge was constructed by the China State Construction Engineering Corporation and financed by the Islamic Development Bank and the Malian government.
The town is strategically located with road links (unpaved) to the desert Kidal Region to the north and to Niamey, the capital of Niger, to the south. The road to the south runs along the left bank of the river. The town of Ansongo is 103 km (65 mi) from Gao. The border with Niger is just south of the village of Labbezanga, a distance of 204 km (127 mi).
There are also seasonal ferry services on the Niger River. A service between Gao and Koulikoro, a distance of 1380 km (860 mi), is managed by the Compagnie Malienne de Navigation (COMANAV). It usually operates from the end of July, after the annual rains when there is sufficient water in the river, until mid November. Smaller boats are able to operate for a longer season between Bourem and Ansongo.