Stephen Bathory, Duke of Transylvania, ascended the Polish throne in 1575 as the husband of Anna the Jagiellonian, youngest daughter of Sigismund I and Bona Sforza. His reign began at a difficult time for Poland - the male line of the Jagiellonian dynasty, which had ruled in Poland since the late 14th century, had become extinct and Poland became an elective monarchy. Henceforth all the male members of the nobility and gentry could vote for their king. However, in 1574, the first elective king of Poland, Henri de Valois, fled back to France after barely four months on the Polish throne. The royal treasury was empty, and the eastern marches were being menaced by Ivan IV the Terrible, who had successfully accomplished the conquest of several parts of Livonia.
Despite the enthusiasm on the part of the nobility and gentry, his electors, who proclaimed Bathory king on 15 September 1575, the Emperor Maximilian also stood in the royal election and put forward his claim to the Polish throne. One of the first democratic elections in modern history resulted in a 'double election win': Bishop Uchański proclaimed Maximilian king of Poland, and the country nearly erupted in civil war. However, the Emperor died before the war could start. In order to establish Bathory's rights to the Polish throne, he was married to Anna, the last remaining Jagiellon. The Polish princess was over fifty-two at the time, nearly ten years older than her husband. The marriage was thus not the best match ever, yet in view of the claims of other houses related to the Jagiellons, it gave Bathory a chance to hold on to the crown.
The reign of the newly elected king was highlighted by a series of wars. Most of them took place beyond Poland's eastern borders, since in 1563 the Russian Tsar Ivan IV the Terrible had captured the fortress of Polotsk and Livonia all the way to the River Dvina (Daugava). The uncertain situation within Poland made him attempt a further expansion, which was met with a vigorous repulse by Bathory. After signing a treaty with King John of Sweden in 1579, the King of Poland, at the head of a joint Polish-Lithuanian-Swedish army, entered the captured territories and regained Polotsk. In 1580 he recaptured the fortress of Wielkie Łuki, and in 1581, after surrounding Pskov, began peace negotiations with Ivan the Terrible, which ended with a peace treaty signed in Jam Zapolski (1582). Under this treaty, Poland regained Livonia, while the Tsar kept the parts of Russia which had been captured by the Poles.
The domestic situation also ended with a conflict. In 1577 the city of Gdańsk, rebelled against the King in support of the Habsburgs. The merchants of Gdańsk relied on the Danish fleet to protect the city from the sea, while Scottish mercenaries strengthened its ground forces. Faced with this situation, Bathory decided not to take the city by force; instead he opted for a tax on the city amounting to two hundred thousand Polish zlotys, which he used for the war against Ivan the Terrible.
Stephen Bathory died on 12 December 1586, while preparing another expedition to the East and trying to muster allies against the growing threat from the Turks. His death was so sudden that his two court physicians were unjustly suspected of poisoning him.