Jayapala fought against the Ghaznavids in the Gandhara region of Ancient India, which is now in modern-day north-eastern Afghanistan and north-western Pakistan, until finally being defeated in Peshawar by superior forces of the latter.