The establishment of a single state in Azerbaijan happened between the 15th century and the 18th century. This period is very important in the history of Azerbaijan. The ruler Shah Ismail Khatai (1501-1524) who was of Azerbaijani origin, united all the territories of Azerbaijan under his control. He founded the Safavid dynasty with Tabriz as its capital. During the rule of the Safavis, the Azerbaijani language also became the only official language. After the Safavid dynasty ended, Nadir Shah Afshar (1736-1747), an Azerbaijani commander founded the Afsharid dynasty (1736-1796) named after himself, and continued to rule over Azerbaijan's territories. He strengthened the borders and in 1739 invaded North India including Delhi. After Nadir Shah's death, his dynasty weakened and in the second part of the 18th century resulted in the formations of new smaller states.