At the dawn of the Middle Ages, India was divided into many small countries of the most diverse type. The boundaries between them changed even faster than the dynasties and ruling rajas. In North India, a large state association, Magadha, was formed. It occupied the middle reaches of the Ganges River. The rise of the Magadha began at the end of the third century, when Gupta was established by the government. He took the title of Maharaja and initiated the Gupta dynasty. His heyday Magadha reached during the reign of his grandson Chandragupta, who united North India. The Gupta state has become one of the largest empires of the early Middle Ages in the East.
In the VI. the Gupt empire, having existed for about two centuries, disintegrated. The final blow to her caused the invasion of the Ephtalites, who came from Central Asia. After lengthy wars in 528, the gupta defeated the army of the Ephthalites and put an end to the invasion. But this confrontation weakened the Gupt empire, and it soon disintegrated.
On the Indian territories repeatedly attacked the Arabs. Starting from the 11th century, these lands were wanted by the Turkic Muslims. In 1001, the ruler of the strong and bellicose Turkic-Iranian state of Ghaznavid, Sultan Mahmud Ghaznavi, made his first trip to India. The easy victory and rich military extraction led to the fact that in subsequent years he devastated India 16 more times. Mahmoud was returning home accompanied by tens of thousands of prisoners and caravans laden with gold, silver and jewels. Its capital, the city of Ghazni, grew into luxurious buildings, built mostly by Indian captives.