In the winter of 1663, Ottoman Grandvizier Ahmed Köprülü marched into Hungary and camped there for the winter. Once again the Styrians, the gatekeepers for Central Europe, prepared for invasion. During the ensuing months they called up 6,000 men, fortified Graz with 42 cannon, dug trenches, and built obstacles. In Vienna Emperor Leopold I assisted them by raising a large army and seeking allies. King Louis XIV of France sent 7,000 men under the command of the Count of Coligny. The German states did likewise. The Emperor also received funds from the Pope and from the court of Spain.
In July 1664, the Grandvizier advanced to Styria's border and on August 1, 1664, confronted a waiting allied Imperial, German and French army between St-Gotthard, a Hungarian village, and Mogersdorf on the Styrian border. Led by Imperial Field Marshal Raimund Count Montecuccoli, the outnumbered Imperial forces defeated the Ottomans. The young and impetuous Duke of Lorraine, Charles V, future brother-in-law of the Emperor, drove his cavalry regiment through the enemy's left wing, and captured the Turkish flag as a trophy. With the climatic defeat of the Ottomans at the siege of Vienna in 1683, Austria and Hungary were at long last secure from the Turkish threat.