In 1038, Togrul-bek, the grandson of Seljuk, the head of the Kynyk tribe, and his army occupied Nishapur, one of Iran’s richest cities in Khorasan, where he was proclaimed sultan.
However, a year later, the ruler of the Ghaznavid power Masud Ghaznavi managed to expel the Turkmens from there.
But soon there was again a break in the exhausting military confrontation in favor of the Turkmens. The wars, accompanied by destruction and plundering, led to the decline of the economy of Khorasan, and Masud sought funds to resist the Turkmen onslaught by increasing taxes on the subjects, conducted mass mobilizations of the working people. In the end, the inhabitants of Khorasan even began to hope for the victory of the aliens, who often behaved more gently than their own officials and military authorities: the basis of the Turkmen army was still tribal militias, and the Turkmen did not need to mobilize local farmers and urban artisans for the war, and the provisions were obtained by hunting wild animals. The Gaznevid power began to be shaken by uprisings of the people, ruined by military taxation, and Masud had to divert considerable forces to suppress them.
In May 1040 Masud’s numerous army suffered a crushing defeat from Togrul-Bek’s forces at the battle of Dandanakan. Masud was forced to flee to Afghanistan. After the Battle of Dandanakan, the military power of the Ghaznavid state was in complete decline.
Battle of Dandanakan
Turkmens began to seize one blossoming eastern province after another, driving out the remnants of Masud’s troops from everywhere and seizing the lands of other rulers. During the 40s they seized most of the whole of Iran, part of the Khorezm region on the Amu Darya River in their native Central Asia, some territories in northern Afghanistan, and in the west they reached the Byzantine borders in Asia Minor.
It is noteworthy that neither Togrul-Bek nor Masud were formally sovereign rulers in their states: they were considered subjects of the caliph, the supreme ruler of all Muslims, who sat in the Iraqi city of Baghdad. By that time, however, the power of the caliphs had become an absolute fiction: they issued all their decrees under the direct dictate of the Iranian Buid party, which had taken control of Baghdad.
The Buyids were Shiites, that is, they belonged to the religious trend that believes that the power on earth should be in the descendants of Caliph Ali — a cousin of the founder of Islam, the Prophet Muhammad, and the daughter of the Prophet Muhammad Fatima.
Baghdad caliphs were descendants of Abbas — uncle of Prophet Muhammad.
Not daring to overthrow the Abbasid caliph dynasty, which could incur the wrath of the majority of the population of the Islamic world Sunnis — orthodox Muslims, the Buids, nevertheless, in every possible way limited the capacity of the caliphs: they could not even take money for personal needs from the treasury without their consent. For religious reasons, the rulers of Sunni states took nominal oaths of allegiance to the Baghdad caliphs, but did not obey their decisions as dictated by the Shiite party.
Religious-political contradictions in Iraq did not have the best effect on its defense capability: systematically the fiefdom of Muslim spiritual leaders and the cradle of the most ancient civilizations was exposed to raids of other Oghuz tribes coming from Transcaucasia, and to invasions of Shiite rulers of Egypt.
Hoping to save Iraq from robbery invasions and himself from the burdensome tutelage of the Buids, Caliph al-Qaim began to call Togrul-Bek to Baghdad. In 1055 Turkmens entered the capital of the Caliphate. Al-Qaim confirmed for Togrul-Bek the title of Sultan, and also endowed him with the title of «King of East and West». The Caliphs were freed from the tutelage of the Buyids, were given the opportunity to independently dispose of their private lives, they were returned to the respectful treatment befitting the leaders of the Islamic world. However, they did not receive real political power: now all their decrees, including in the management of Baghdad and Iraq, were dictated by the Seljukid rulers.
Wishing to protect themselves from the raids of neighbors, some feudal lords of Azerbaijan recognized the powerful Togrul-Bek as their supreme ruler. Relying on their support, the Turkmen commanders seized South Transcaucasia, through which they led their troops to conquer Asia Minor, then belonging to the Byzantine Empire, the heir of ancient Rome.
In 1054 Turkmen troops were repulsed from the Armenian city of Manzikert (modern Malazgirt in Turkey) and Togrul-Bek’s father-in-law was captured and executed. Then Seljukids moved to systematic exhausting tactics of conquering Asia Minor: their troops began to systematically invade its territory, ruining farmlands, stealing livestock, forcing the local population to leave their habitual places of residence and move to the west — to the depths of the empire. Having made a devastating raid, the Turkic warriors retreated back to Transcaucasia and Iraq.
Due to the ensuing economic desolation, the Byzantine garrisons stationed in Anatolia began to lack food, horses, and forage. Eventually, in 1071, the army of Alp Arslan, Togrul-Bek’s nephew, took Manzikert, and ten years later the Seljukids took possession of all Anatolia, except for a few areas of no particular strategic importance.