Kindly refer below our standard reply to similar queries.
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai
FATWA DEPT.
In principle, if a Muslim country is attacked, they have a right to defend
themselves and declare Jihaad. Jihad will be Fardh-e-Ain upon the males of
that area (in this instance, Afghanistan).
If they are unable to defend themselves, then the obligation extends to
those closest to them, Pakistan. Thereafter, the obligation will extend
accordingly.