Pahlavi is a term that refers: (1) to a script used in Iran derived from the Aramaic script, and (2) more broadly, to Middle Persian, the Middle Iranian language written in this script. The Pahlavi script was used broadly in the Sasanid Persian Empire to write down Middle Persian for secular, as well as religious purposes.
The modern-day descendent of Middle Persian is Modern Persian. The latter is distinguished from the former by, among other things, being written in a different script, the Perso-Arabic script, and by a large number of Arabic loanwords. Pahlavi 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 Sassanid Iran (224 to ca. 650) before Iran was defeated by the Arab armies that introduced Islam.
The Middle Persian language was also written down in the Manichean script by followers of that religion.
The Avestan alphabet, the native name for which is din dabireh or din dabiri, is a writing system developed during the Sassanid era (226-651) to render the Avestan language.
Alternatively, the need for such an alphabet may have become apparent during the reconstruction of the royal library by Ardashir I (226-241) and Shapur II (309-379), that was said to have been destroyed by the Alexander's troops in 330 BCE (see below).
Pahlavi script had at most 22 characters (the number varied by region and epoch), and as "Book Pahlavi", the most common form of the script, had only 12 characters representing 24 sounds.