No, he wasn't - and by the way, this has nothing to do with the Middle Ages.
First of all, excommunication was a thing long before it was formalised in canonic law. The first Christians were a small, conspiratorial flock of really devout people whose religious beliefs were often outlawed, their rites and practices threatened with capital punishment, and who seldom held any mundane power at all. The threat of being cast out of that small group was both the most serious punishment imaginable as well as the only meaningful one they could administer, lacking real power and authority.
Secondly, there are two kinds of excommunication:
By (canonic) law;
by judgement/verdict.
The latter means means that anybody can excommunicate anyone within their respective jurisdiction.
Who has jurisdiction in the Catholic Church? Councils (for the whole church), bishops (for their dioceses), patriarchs, primates, metropolitans (for their respective territories), the heads of monastic orders (for their order), and everyone holding special jurisdiction derived from a superior (jurisdictio vicaria, i.e. vicar-generals of the pope).
The pope is the bishop of Rome and derives his authority from apostolic succession, which means that he has ultimate and superseding jurisdiction over the entire Christendom. That's the reason why only the pope could excommunicate, say, a medieval emperor, since those didn't belong to any particular diocese.