The question, as is, covers a long period between Alexander (d. 323 BCE) and Mahmud of Ghazni (b. 975 CE) and the ethnic and religious influence changed extensively over the period of more than a 1000 years.
So, I will focus on Gandhara during the early stages, immediately post-Alexander, and with particular emphasis on Buddhism (Gandhara was in the question title before subsequent modification).
Ashoka of Mauryan Emprire
Ashoka (son of Bindusara) would be the start of Buddhism in Gandhara. He was a significant emperor of the Mauryan Empire (322 BCE - 185 BCE). This period is much earlier than the Ghaznavid Empire (975 CE - 1187 CE).
Buddhism under Ashoka
The significance of Ashoka and Mauryan Empire to Gandhara, in terms of acceptance of Buddhism is on several levels:
- The Mauryan Empire was the first empire immediately after Alexander to adopt Buddhism as one of it's religion, i.e. early stages of Graeco-Buddhism. To be clear, Buddhism was the dominant religion of the Kushan Empire and the basic repertoire of Buddhist iconography (art style) was developed during the Kushan period around the first century CE, but this was much later than the Mauryan period.
- Ashoka started his career in Gandhara as a governor before he became the Emperor (see Wikipedia entry on Ashoka)
- Ashoka was the first Mauryan Emperor to convert to Buddhism, after he became the Emperor
- He actively promoted Buddhism throughout the empire (and beyond) with his edicts on Buddhism.
- As an indication of the close ties to Gandhara, Ashoka's son, Kunala, was also the governor before he became the next Emperor.
Ashoka succeeded Bindusara as emperor in 270 BCE, while his son, Kunala, became the governor of Gandhara ...
source: The Grandeur of Gandhara (Algora Publishing, 2011)
Ashoka's legacy is the spread of Buddhism, to Gandhara and the rest of the world - source:
He did with Buddhism in India what Emperor Constantine did with Christianity in Europe and what the Han dynasty did with Confucianism in China: he turned a tradition into an official state ideology and thanks to his support Buddhism ceased to be a local Indian cult and began its long transformation into a world religion. Eventually Buddhism died out in India sometime after Ashoka’s death, but it remained popular outside its native land, especially in eastern and south-eastern Asia. The world owes to Ashoka the growth of one of the world’s largest spiritual traditions.