The word Urdu is derived from the same Turkish word that has given English horde. Urdu arose in the contact situation which developed from the invasions of the Indian subcontinent by Turkic dynasties from the 11th century onwards, first as Sultan Mahmud of the Ghaznavid empire conquered Punjab in the early 11th century, then when the Ghurids invaded northern India in the 12th century, and most decisively with the establishment of the Delhi Sultanate.
The official language of the Ghurids, Delhi Sultanate, the Mughal Empire, and their successor states, as well as the cultured language of poetry and literature, was Persian, while the language of religion was Arabic. Most of the Sultans and nobility in the Sultanate period were Turks from Central Asia who spoke Turkic as their mother tongue. The Mughals were also Chagatai, but later adopted Persian. Muzaffar Alam asserts that Persian became the lingua franca of the empire under Akbar for various political and social factors due to its non-sectarian and fluid nature. However, the armies, merchants, preachers, Sufis, and later the court, also incorporated the local people and the medieval Hindu literary language, Braj Bhasha. This new contact language soon incorporated other dialects, such as Haryanvi, Panjabi, and in the 17th century Khariboli, the dialect of the new capital at Delhi. By 1800, Khariboli had become dominant.
The language went by several names over the years: Hindawi or Hindī, "[language] of India"; Dehlavi "of Delhi"; Hindustani, "of Hindustan"; and Zaban-e-Urdu, "the language of the [army] camp", from which came the current name of Urdu around the year 1800.
When Wali Mohammed Wali arrived in Delhi, he established Hindustani with a light smattering of Persian words, a register called Rekhta, for poetry; previously the language of poetry had been Persian. When the Delhi Sultanate expanded south to the Deccan Plateau, they carried their literary language with them, and it was influenced there by more southerly languages, producing the Dakhini dialect of Urdu. During this time Hindustani was the language of both Hindus and Muslims. The communal nature of the language lasted until it replaced Persian as the official language in 1837 and was made coofficial along with English in the British Raj. This triggered a Hindu backlash in northwestern India, which argued that the language should be written in the native Devanagari script. This "Hindi" replaced traditional Urdu as the official register of Bihar in 1881, establishing a sectarian divide of "Urdu" for Muslims and "Hindi" for Hindus, a divide that was formalized with the division of India and Pakistan after independence from the British, though there are Hindu poets who continue to write in Urdu to this day.
Although there have been attempts to purge Urdu and Hindi, respectively, of their Sanskrit and Persian words, and new vocabulary draws primarily from Persian and Arabic for Urdu and Sanskrit for Hindi, this has primarily affected academic and literary vocabulary, and both national standards remain heavily influenced by both Persian and Sanskrit. 1