Theory:

In the 8th century A.D, Arabs conquered the Sind. But they were not able to expand further into the Gangetic plains and the Deccan, due to strong resistance by the Indian rulers.
 
Sindh.svg
Arrival of Turks in India
The Tripartite Struggle for the fertile Gangetic Valley (Kanauj), was between three main Rajput clans: the Pratiharas, the Palas and the Rastrakutas. This struggle lasted 200 years and weakened all of them which enabled the way for the Turks.
Kannuj.svg
The Kanauj Triangle 750-900BC
  
Mahmud of Ghazni (A.D. 997 -1030)
  • Mahmud of Ghazni invaded India 17 times. Shahi, Kanauj, Gujarat, Kashmir, Nepal, Malwa and Bundelkhand were the important kingdoms.
  • In 1001, Mahmud raided against the Shahi kingdom, in which its king Jayapala was defeated.
  • In 1011, he invaded Nagarkot in Punjab hills and Thaneshwar near Delhi and plundered the rich temples and cities of North India.
  • In 1018 Mahmud raided the sacred town of Mathura and Kanauj.
  • In 1024 A.D. Mahmud defeated the Solanki king Bhimadeva I and looted the town Anhilwad.
  • Mahmud's last campaign in India: he looted the great Somanath temple. He died in 1030 A.D.
Battle of Waihind (1008 A.D.) happened near Peshawar, between Anandapala (successor of Jayapala) and Mahmud of Ghazni. Anandapala was defeated in this battle.
Muhammad of Ghor (1149 - 1206)
Muhammad Ghori, a slave of Ghazni, became independent after the death of Mahmud and brought Ghazni under his control. He extended his empire by conquering India. Muhammad Ghori was killed while camping at the Indus. His general Qutbud-din Aibak declared himself the Sultan of Delhi in A.D. 1206. Thus the rise of the Slave dynasty begun.
 
800px-Painting_of_Battle_of_Tarain_-_Rajput_States.jpg
A painting depicting the Battle of Tarain
 
The Battle of Tarain (A.D.1191 - 1192)
Battle between Muhammad Ghori and the confederacy formed by Prithiviraj Chauhan. In which Muhammad was defeated in the first battle near Delhi in 1191A.D. In the second battle of Tarain (A.D.1192), Muhammad gathered a vast army and ultimately defeated the army of Prithiviraj Chauhan. Thus the first Muslim kingdom was firmly established in India at Ajmer, and a new era in the history of India began.
Reference:
1. https://commons.wikimedia.org/wiki/File:Painting_of_Battle_of_Tarain_-_Rajput_States.jpg