As the Sikhs consolidated their power, and as Durrani Afghanistan retreated into tribal civil war, eight hundred years of history – beginning with the invasions of Mahmud of Ghazni (971–1030) – drew to a close: since 1799 no Afghan has succeeded in invading the Punjab plains or raiding the rich plains of Hindustan beyond.