Who was the king of Sweden who turned the tide of the war in favor of the Protestants until he was killed in battle?
Gustavus II Adolphus, one of my personal favorite leaders in history.
His time came during the 30 Years' War (1618-1648), a truly brutal conflict that cost the lives of millions. The war began when the Protestants in Bohemia were unhappy that their new emperor would be a Hapsburg Catholic. (The Hapsburgs were a strong Catholic family with many territories in Europe). Bohemian delegates tried to negotiate some sort of religious tolerance agreement with the Hapsburgs,- otherwise, they would certainly be persecuted for their religion. However, the Hapsburg officials ended up getting tossed out of a window in Prague Castle by angry Bohemian noblemen. The Bohemians chose a Protestant as their king, and thus began the war.
The tossing of the Hapsburgs out of the window is known as the Defenestration of Prague.
The first couple of years were a disaster for the Protestants. The new king of Bohemia was overwhelmed by the might of the Hapsburg army, led by the veteran general Johannes von Tilly. More than a million peasants starved or ran away during the conflict, which ended in Bohemian defeat at the Battle of White Mountain.
Other Protestant nations like Britain and Denmark tried to intervene, but their armies were either destroyed by the Catholics or died of plague. But, in the summer of 1630, the Swedish army under King Gustavus II Adolphus took the field, subsidized by the French (who were worried that the Hapsburgs were becoming too powerful). Gustavus had reorganized his army - it was stronger, faster, and deadlier under his leadership. In the fall of 1631, he marched his army against Tilly.
Gustavus II Adolphus
At the Battle of Breitenfeld, Gustavus and his army crushed the Catholics and pushed them back to their own territory. Another victory the next spring further pressed the Catholics back, and as a bonus for the Protestants, Tilly was killed. Then, in November 1632, at the Battle of Lutzen, the Swedes scored their greatest victory - and worst loss. Gustavus was killed shortly after the battle.
Gustavus' contribution to the war was huge. He completely turned around the war in the favor of the Protestants. At the time of his intervention, the Protestants were on their knees, and ready to surrender; he revived their cause and won victory after victory. If he had not died, the war would have probably ended in the Protestants' favor. Regardless, he managed to prevent an early and unfair peace to the Protestants and gave military historians many strategies and tactics to study and learn.