The village's name is spelled differently in the records, and its status changed many times: khanate, governorate, rural society, Soviet settlement and finally a part of Baku.
The exact meaning is unsettled — there are no written sources, and most versions rest on folk etymology. Four are common: “Piri-Shahin,” the shrine of a healer named Shahin; “Piri-shahi,” a shrine visited by the shah; “Pir-ushagi,” the children of the shrine, meaning those living around it; and an Arabic reading, “Pir ushshaq,” the lovers of the shrine.
The spelling was unstable too. The 1856 “Caucasian Calendar” lists a village of the Mashtaga district as “Pirshafik” — most likely a dot over the Arabic letter qāf was lost and it was read as fā. B. V. Miller's work of the late 1920s uses the form “Pir-Shahi.”
From khanate to governorate
In the second half of the 18th century Pirshagi belonged to the Baku khanate; in 1806 the khanate passed to the Russian Empire. On 14 December 1846 the Shemakha governorate was created, taking in the former khanate; after the destructive Shemakha earthquake of 1859 the governorate offices moved to Baku and it was renamed the Baku governorate.
It was a state-owned village. In the 1880s Pirshagi formed a separate rural society, and by the early 20th century it belonged to the 4th police precinct of the Balakhany-Sabunchu police district, whose office was in the village of Balakhany.
In 1920 Baku's Lenin district was created, centred on Sabunchu. As of 1 January 1961 it included the Pirshagi rural soviet, covering three settlements — the village itself and the settlements at fisheries No. 1 and No. 2. By 1 January 1977 Pirshagi formed a separate settlement soviet.
In the Soviet years sanatoria and Young Pioneer camps were opened here to use the settlement's natural setting — a large share of residents worked in them. The school at first occupied private houses and only in 1934 moved into a new building. The Friday mosque was closed and long served as a grain store.
From Tats to an Azerbaijani-speaking settlement
Until the first quarter of the 20th century the residents were usually recorded as Tats. The 1870 settlement lists give 130 households and 598 residents; the 1886 family lists give 798 people, all Shia Tats. As of 1 January 1903 the figure is 1,045.
By the late 1920s the village had shifted to Turkic speech. The Soviet Iranist B. V. Miller, surveying the Tats in 1928, noted that “only five years ago Tat speech could be heard here; now it has been displaced by Turkic.” Later censuses show steady growth: 2,470 in 1970, 3,216 in 1979 and 4,145 in 1989.