Excommunication was a powerful tool of the popes, but like any tool, you use it too much and after awhile it looses its edge.
Although many Christian powers have tried to control the papacy in one way or another (See Byzantine Emperors, And Holy Roman Emperors and [Ceaseropapism] (http://en.wikipedia.org/wiki/Caesaropapism) ) it was towards the end of the middle ages France effectively gained control over the papacy, and it was moved to Avignon. Technically this was a new papal States and not part of the French Crown, but it was on the French side of the Pyrenees and Alps and most non-French Catholic princes felt the Avignon papacy was a French puppet.
This move was the result of the conflict between the French king Philip IV (Sometimes called "The Fair") and pope Boniface VIII. The issue was whether or not the French king should be able to tax the French Clergy i.e. who were the French clergy ultimately responsible too, the local prince or the pope? Philip IV wanted to be seen as a pious Christian prince, and war with a corrupt pope would not have been all that novel in the high middle ages. During the course of the conflict the pope tried to use excommunication against Philip and all his army, but the more he would use it the more it stopped being taken seriously. After all, if the pope is corrupt and a heretic, his orders of excommunication meant nothing and why would a good Christian prince like Philip VII, who's descended of King Saint Louis, be warring against a true pope?
So over time excommunication stooped having the force it could, partly because some popes over used it. Eventually the papacy's involvement in Avignon would set the state for the "Great Western Schism" which began when the papacy tried to move back to Rome, and further eroded the pope's authority.
By the time the Renaissance comes around the papacy had only just returned to Rome from France, and partly because the French kings had a claim on part of Italy, but also simply to show the pope who's boss, French kings made repeated invasions of Italy at the close of the Middle Ages and during the Renaissance.
The pope in response would appeal to the other Christian Princes for help (Spain and England, at least until the reformation, were usually willing to back the pope against France because "Screw France!"). The Borgia, for example, was a Spanish Pope and so could in theory call upon Spanish kingdoms to counter France. Pope's like Sixtus IV and his nephew the later pope Julius II had virtually given up on using excommunication except as a disciplinary action against local bishops and priests. It was these latter popes who formed the Papal Swiss Guard we are all familiar with today.
Edit: Added wiki links, tried to fix grammar... too tired.
Sometimes, they weren't even subtle about it. A perfect, and somewhat shocking example, involves Pope Boniface and the famous papal bull Unam sanctum. In short, the Unam sanctum declared the supreme authority of the Pope over all Christians in the Church. In other words, all Catholics were below the Pope. King Philip IV of France would have none of that. French soldiers attacked the residence of the Pope and nearly beat him to death.
This just one example, and it does not look into it any broad scope. As far as I know, most of the cardinals supported Boniface.
If you want justification, King Philip IV would try to gain control of the papacy by forcefully moving it to a French city named Avignon. Obviously, he had no intention of serving the Pope.
You can read about it here: http://www.fordham.edu/halsall/source/1303anagni.asp
e: FourOfTwenty provides a more complete answer.
The Papacy isn't a purely religious office. Even today, the Pope is the Sovereign of the Vatican City and holds absolute secular power within its boundaries. The same was true of the Papal States when they existed. So it was quite possible for the Pope to get involved in wars purely in his capacity as a temporal ruler.
Of course this temporal ruler happened to inhabit the same body of the head of the Catholic faith so depending on how unscrupulous a Pope might be, going to war with him might not be the brightest idea.
Innocent III's campaigns provide a very interesting look at the Catholic Church acting as a nation state. His conquest of the Cathars might be fun reading for you. In this particular instance Innocent justified a fight against Gnostics for heresy but was most likely protecting/expanding (can't remember) papal property.
This is just one of many Innocent III episodes. His story is truly fascinating.
Read this in a Medieval history course in school and loved it.