Around 500 years ago, Khas people from the Karnali-Bheri-Seti basin migrated eastward, bypassing inhospitable Kham highlands to settle in lower valleys of the Gandaki Basin that were well-suited to rice cultivation. One notable extended family settled in the Gorkha Kingdom, a small principality about halfway between Pokhara and Kathmandu. In 1559 AD a Lamjunge prince, Dravya Shah established himself on the throne of Gorkha with the help of local Khas and Magars. He raised an army of khas with the commandership of Bhagirath Panta. Later, in the late 18th century his heir Prithvi Narayan Shah raised and improvised an army of Chhetri, Thakuri, Magars and Gurung people and possibly other hill tribesmen and set out to conquer and consolidate dozens of small principalities in the Himalayan foothills. Since Gorkha had replaced the original Khas homeland, Khaskura was redubbed Gorkhali "language of the Gorkhas".[citation needed]
The most notable military achievement of Prithvi Narayan Shah was conquest of the urbanized Kathmandu Valley, on the eastern rim of the Gandaki basin. This region was also called Nepal at the time. Kathmandu became Prithvi Narayan's new capital, from which he and his heirs extended their domain east across the Koshi River basin, north to the Tibetan Plateau, south into the plains of North India, and west across the Karnali/Bheri basin and beyond.[citation needed]
Expansion – particularly to the north, west, and south – brought the growing state into conflict with the British and Chinese. This led to wars that trimmed back the territory to an area roughly corresponding to Nepal's present borders. Both China and Britain understood the value of a buffer state and did not attempt to further reduce the territory of the new country. Since the Kathmandu Valley or Nepal had become the new center of political initiative, this word gradually came to refer to the entire realm and not just the Kathmandu Valley. So Gorkhali came to be known as Nepali.[citation needed]
In all these years, Nepali has had influences from many languages. While Nepali is technically from the same family as languages like Hindi and Bengali, it has taken many loan words. Words like dhoka "door", jhyāl "window", pasal "shop", kukhura "rooster" and rāngo "water buffalo' have Tibeto-Burmese roots. Words like sahīd "martyr" (ultimately from Arabic) and kānun "law" (ultimately from Greek, came from Persian into Nepali, as the former functioned as the literary language of much of the Muslim world for over a millennium. Many English words are in use nowadays due to the rising popularity of the United States of America in the region and the previous British aid at schools and other fields.
Nepali is spoken indigenously over most of Nepal west of the Gandaki River, then progressively less further to the east