Since Christ gave Peter and all succeeding popes the power to bind and to loose, John Paul II's excommunication of Lefebvre was valid and just.
As has been pointed out, there is historical precedent for decrees of excummunication being nullified. The power of the keys does not preclude the Pope from error in matters of discipline. The same power allows the possibility of JP2's sucessors modifying or nullifying something he did as it applies to disciplinary matters.
If the Pope witnessed a marriage, let's say, and it was later found that there was some defect that would be grounds for nullity, the marriage would still be null and void, regardless of who pronounced the couple married. It is, in fact, an error to believe that the Holy Ghost protects the Pope from error in everything that he says or does.
John Paul II formally excommuncated Lefebvre and the four bishops with his decree "Ecclesia Dei." Lefebvre did not merely incur an automatic excommuncation as you claim (although he may have incurred it in addition to the formal excommunication!).
What does the
document say, exactly?
Hence such disobedience - which implies in practice the rejection of the Roman primacy - constitutes a schismatic act. In performing such an act, notwithstanding the formal canonical warning sent to them by the Cardinal Prefect of the Congregation for Bishops on 17 June last, Mons. Lefebvre and the priests Bernard Fellay, Bernard Tissier de Mallerais, Richard Williamson and Alfonso de Galarreta, have incurred the grave penalty of excommunication envisaged by ecclesiastical law.
The law referenced, Canon 1382, states that a bishop who consecrates another without a Papal mandate incurs excommunication
latae sententiae ("automatic"). The other type of excommunication,
ferendae sententiae, is imposed by a superior. This, I presume, is the "formal" excommunication you claim JP2 imposed. Well, clearly, he didn't. He only confirms, rightly or wrongly, that
latae sententiae excummunication had been incurred. Seems like I'm splitting hairs, I know, but it's an important distinction to make, as most I've met believe it happened the way you say it happened.
Further, Canon 1323.4 states that even where an offence carrying a penalty has been committed, the penalty is not incurred if the act was performed out of necessity unless it be something intrinsically evil or damaging to souls. This applies
even if the state of necessity did not actually exist except in the mind of the person committing the act:
"If one inculpably thought there was [a state of nesessity]
, he would not incur the penalty." (Canon 1323, 70)
But wait. The Canon goes even further:
"If one culpably thought there was[a state of necessity]
, he would still incur no automatic penalties." (Canon 1324, §3; §1, 80).
In sum, then, even if Archbishop Lefebvre was
knowingly in error thinking that a state of necessity existed, there's
still no automatic penalty is incurred, and if that's true, the excommunications never happened.
There's more to the case of "that ungrateful schismatic" than most people realize.