The Papal States had a military throughout much of its existence. However, its success rate in using its military to dictate the course of events was very low. The Papal States were at best a regional power with influence beyond its military capabilities, but they could project power outside their borders on very rare occasions. Larger continental powers dwarfed papal military forces most of the time.
The end of Papal military forces came about in the 1860's during the process of Italian unification. Papal armies were handily defeated in the field and fell back to Rome in 1860-61. It wasn't force of arms that kept the new Italian state out, as their military power was unquestionably superior to that of the papacy. Papal military contingents remained in the city, but the real reasons for not invading were twofold: a reluctance to attack the papacy directly and a lack of desire to engage the French troops on loan to the papacy. The former reason was opposed by a good number of Italian leaders, but the second reason was pretty convincing--nobody in Italy thought they could win a war with France at that time. Then in 1870 we have the Franco-Prussian war, and the French troops were recalled to help in the defense of France. Rome fell shortly thereafter.
Since then, the military forces of the papacy have been miniscule. "The Roman Question" of how to use Rome as both the capital of the new Italian State as well as the head of Roman Catholicism lingered until 1929. In that year the Lateran Concordat (or Lateran Accords, or Lateran Treaty) was signed, creating the new nation of the Vatican City. Article 24 requires neutrality in foreign affairs for the Vatican:
In regard to the sovereignty appertaining to it also in international matters, the Holy See declares that it desires to take, and shall take, no part in any temporal rivalries between other States, nor in any international congresses called to settle such matters, save and except in the event of such parties making a mutual appeal to the pacific mission of the Holy See, the latter reserving in any event the right of exercising its moral and spiritual power.
The Vatican City shall, therefore, be invariably and in every event considered as neutral and inviolable territory.
Since then, the Vatican has had a small military force in the Swiss Guards and a small police force as well. Generally these two forces combined number around five hundred people. They are well-armed, well-trained, and highly motivated--but utterly outclassed by most any military force and a large number of police forces (for instance, this site claims that there are 34,000 officers in the NYPD, which would dwarf the capabilities of the forces available to the papacy by a large margin). There has been no serious attempt to expand the papacy's military capabilities outside of security and updating their equipment and doctrine.