Shah used as a last name by Jains and Hindus is unrelated. See Shah (Jain family name)
"Shah" was the title of Iranian kings including the Achaemenid dynasty which unified Persia and created a vast intercontinental empire until it was overrun by Alexander the Great. The full title of the Achaemenid rulers was xšāyaθiya xšāyaθiyānām, "King of Kings", corresponding to Middle Persian šāhān šāh, literally "kings' king", and Modern Persian shāhanshāh (شاهنشاه). In Greek this phrase was translated as "βασιλεύς τῶν βασιλέων (basileus tōn basiléōn)", "king of kings", in rank rather equivalent to emperor. The Indian counterpart of shahanshah was rajadhiraja or kshetra-pati (more toward Padishah). Both were often shortened to their root, shah viz. basileus.
In English its use as title for the king of Persia is recorded since 1564, as shaw (or shaugh), and for long it remained common to render it in European languages by kingly rather than imperial titles. Via its Arabic form (also shah) it was the root of the western words for chess and check (as in "check mate").
In western languages, the term shah is often used as an imprecise rendering of shāhanshāh (meaning king of kings). Usually shortened to shāh it is the term for an Iranian monarch and was used by most of the former rulers of the Iranian empires, many nationalities of Iranian origin, or under cultural influence.
The term shah or shahanshah has roughly corresponded to Persia since the Achaemenid Persian Empire (which had succeeded and absorbed the Mede state), or the properly Iranian Empire, after its conquest by Alexander the Great who translated it into Greek as basileus ton basileon, also often shortened to basileus.
The title is roughly equivalent in rank to the western emperor and is hence often translated as such in English or its equivalent in other languages. The monarch of Persia (internally always called Iran) was technically the emperor of the Persian Empire (later the Empire of Iran, as Iran was officially known until 1935). However until the Napoleonic era, when Persia was an enviable ally of the Western powers eager to make the Ottoman Sultan release his hold on various (mainly Christian) European parts of the Turkish Empire, and western (Christian) emperors had obtained the Ottoman acknowledgement that their western imperial styles were to be rendered in Turkish as padishah, the western practice was to consider 'king of kings' a particular but royal title.
The last shah of Iran, Mohammad Reza Shah Pahlavi officially adopted the title شاهنشاه shâhanshâh (literally king of kings) and in western languages the rendering as emperor, during his coronation. He also styled his wife شاهبانو shahbânu (empress).
In orthodox Georgia, Giorgi III, grandson of King Bagrat III (who expelled the Turks from the eastern provinces, threw off his allegiance to Byzantium and unified all Georgia, establishing its rule over the Abkhazis, Kartvelians, Ranians, Kakhetians and Armenians), was the first to assume the subsidiary titles of shahanshah (like the Persian king of kings) and master of all the East and West. His reign, and that of his successor, his daughter Thamar the Great, are seen as the 'golden age' of Georgia; the titles of the following Georgian rulers varied significantly from reign to reign, especially while under Muslim and Russian domination, but the last enjoying the traditional titles, was "The Most High King (Mepe-Umaglesi) Irakli I, by the will of our Lord, Mepe-Mepeta ('King of Kings') of the Abkhazis, Kartvelians, Ranians, Kakhetians and the Armenians, Shirvanshah and Shahanshah and Master of all the East and West", with the style of His Majesty (or His Splendour). However, after imperial Russia (also orthodox) had established a protectorate over the 'Transcaucasian' kingdom of Georgia, the emperor recognised the following Russified styles and titles as of 24 September, 1783, old style for its Hereditary Sovereign and Prince (now in fact a Russian vassal): The Most Serene Tsar (i.e. King) (reign name), by the will of our Lord, King (Tsar) of Kartli, King of Kakheti, Hereditary Prince of Samtzkhé-Saatabago, Ruling Prince of Kazakh, Borchalo, Shamshadilo, Kak, Shaki, and Shirvan, Prince and Lord of Ganja and Erivan, with the style of His Majesty, but without the now too imperial subsidiary titles.
However the precise full styles can differ 'creatively' in the court traditions of each shah's 'kingdom'.
Furthermore the title was also used for princes of the blood of a ruler who used an alternative royal style, e.g., the Malik (Arabic for king, so equivalent) of Afghanistan. In the Ottoman dynasty of imperial Turkey, it was part of two styles:
This could even apply to non-Muslim dynasties, e.g., the younger sons of the ruling Sikh Maharaja of Punjab (in Lahore; a Maharajadhiraja): Shahzada (personal name) Singh Bahadur, while the heir apparent was styled Tika Sahib Bahadur
Shah is a common last name in India, like 1Singh and 2Patel. It is mostly seen in the states of Gujarat and Maharashtra. "Shah" is also the last name taken by the royal families in Nepal after King Pritivi Narayan Shah united the kingdom in 1768. "Shah" is also common name of people living in southern Nepal, the Terai region, such as Sarlahi, Rautahat, Bara, Janakpur, and Siraha districts. There are many Shahs living in Nepalese villages such as Arnaha, Laukaha, and Pachrukhi.