Pahlavi is a term used in two senses, to mean 1: Zoroastrian or Sasanian Middle Persian and 2: the writing system used to write (religious and secular) Sasanian Middle Persian and closely similar material, viz. epigraphic Parthian and Middle Persian.
The Zoroastrian or Sasanian Middle Persian language is the only Middle Iranian language that did not fall into complete disuse for hundreds of years. The other Middle Iranian languages, Parthian, Sogdian, Sakan, Khwarezmian and Bactrian now known to us all fell into disuse and were rediscovered only in the 20th century. Zoroastrian Middle Persian, by contrast, was transmitted by the Zoroastrians in Iran and, in particular, in India where the Parsee community, descendants of Zoroastrian exiles from Iran, retained a knowledge of Avestan and Middle Persian and by copying the manuscripts preserved them. Typologically, Middle Persian is close to Modern Persian (just as Middle and Modern English are typologically close) but the latter distinguishes itself from the former by being written in a different script, the Arabo-Persian script, and by a large number of Arabic loan-words. Zoroastrian Middle Persian is the language of quite a large body of Zoroastrian literature which details the traditions and prescriptions of the Zoroastrian religion which was the state religion of Sasanian Iran (224 to ca. 650), before Iran was defeated by the Arab armies that introduced Islam.
See also The Pahlavi dynasty that ruled Iran, 1925 - 1979.