There are some inaccurate assumptions in this thread.
There really is not a 'united' Afghanistan that would come together to fight the Iranian invasion at this point. Even the Afghan resistance against the Soviets was in no way a unified, national movement.
Iran had been supporting some of the militias which would form the Northern Alliance, and continued to do so, which is why their diplomats were in Mazar-i-Sharif.
The Taliban was roughly 25,000 soldiers, the State Dept. estimated (in either 96 or 98), but only 15,000 were Afghans. The rest were foreign volunteers.
There were an estimated, at any time, 28,000 Pakistani nationals fighting in the Afghan Civil War. Only 8,000 were volunteers from madrasas. The other 20,000 were soliders under the control of then Cheif of Arny Staff Pervez Musharraf. In total, an estimated 80,000 to 100,000 Pakistanis trained and fought in Afghanistan.
If Iran is intervening in '98, they will be attacking Pakistani Army units, unless they withdrawl ASAP.
First off, this will come as a surprise to the majority of Pakistan, who did not know military units were actively serving; even the parents of those who died did not know.
Second, how will Pakistan respond to Iran attacking their units?
Pakistan certainly has nuclear capabilities, but would they use it? And then India? The spark of the Kargil War, Operation Badr, was already underway. What about Saudi Arabia?
I see a couple scenarios -
1) Iran invades, Pakistan withdraws convential forces but still supports Taliban and AQ after withdrawl. Saudi Arabia and other Arab states continue to fund them as well. Iran does well conventionally but gets bogged down in guerilla warfare.
2) Iran invades, 'happens' to directly strike Pakistani formations, they duke it out conventionally in Afghanistan. It is up in there air from there.
Do we see an earlier coup in Pakistan?
I have a hard time seeing Saudi Arabia or any of the other Gulf States getting directly involved in the combat, although support may be given.
But, the faultlines along roughly the Sunni/Shia split means it could get globally messy fast.
The US in all honesty has no reason not to back the Saudi/Pakistani efforts. It may be strange to think of a world where the US is in/directly supporting AQ, but if it becomes more of an anti-Shia effort, then the US kind of has no reason not too.