Amidst serious political uncertainties, the Mahmud of Ghazni ascended the throne in 998 at Ghazni (Afghanistan). Mahmud Ghazni conducted 17 raids into India, and fought with the Hindushahi rulers ruling in Punjab and Peshawar. In 1001, he defeated Jaipala of Punjab. The Indian temples were well-known for their fabulous wealth, which made him raids them. Mahmud called himself a butshikan or a breaker of images for Islamic glory. His most daring raids were against Kannauj in 1018 and against Somnath in Gujarat in 1025. Mahmud had an easy way due to the lack of any effective political power. The Somnath Plunder was his last campaign in India. He, however, never tried to annex any of these territories. Plunder, pure and rich, was his only goal.
Back home, after the break-up of the Pratihara empire, a number of Rajput states arose. The most important were the Gahadavalas of Kannauj, the Parmars of Malwa and the Chauhans of Ajmer.
In 1173, Shahabuddin Muhammad (1173-1206 AD), who is also known as Mohammed Ghauri ascended the throne in Ghazni. Meanwhile, the Chauhan power had risen with their many victories. The expansion of their power towards Punjab brought them into conflict with the Ghazanvid rulers.
In Ajmer, a young prince Prithviraja Chauhan had just taken over. Prithviraja was an ambitious ruler, who had defeated many contemporaries. He was immortalized in many legends based on his lifestory later. When he tried to turn towards Punjab, this brought him in direct conflict with Mohammed Ghauri. Thus, there was the First Battle of Tarain in 1191 in which the Ghauri forces were completely defeated.
The Second Battle of Tarain in 1192 was a turning point in Indian history. Ghuari had made careful preparations for the war. When Prithviraja woke up to the danger, he fervently appealed to all other rajas of northern India for help. Many of them did help him, but Jaichand of Kannauj, stayed away. The legend that Jaichand had done so because his daughter had eloped with Prithviraja is historically doubtful because this romantic story was written much later. In the fierce battle, the Chauhan forces were defeated. Prithviraja escaped but was captured near Saraswati. He was allowed to rule over Ajmer for a short time but soon, he was executed on a conspiracy charge. Prithiviraja’s son succeeded him, but Ajmer was soon captured by Turkish rulers. The son moved to Ranthambore and founded a powerful kingdom later. Thus the Delhi area and eastern Rajasthan passed under the Turkish rule.
Ghauri left for Ghazni, leaving India to his trusted slave Qutbuddin Aibak. In 1194, Ghuari returned, defeating Jaichand of Kannauj and looting and destroying Hindu temples in Benares. Thus the battles of Tarain laid the foundations of the Turkish rule in India.