Ioannes Basilius Magnus Imperator Russiae, Dux Moscoviae, by Abraham Ortelius (1574)
In 1558, Ivan launched the Livonian War in an attempt to gain access to the Baltic Sea and its major trade routes. The war ultimately proved unsuccessful and stretched on for 24 years and engaging the Kingdom of Sweden, the Grand Duchy of Lithuania, the Polish–Lithuanian Commonwealth and the Teutonic Knights of Livonia. The prolonged war had nearly destroyed the economy, and the Oprichnina had thoroughly disrupted the government. Meanwhile, the Union of Lublin had united the Grand Duchy of Lithuania and Kingdom of Poland, and the Polish-Lithuanian Commonwealth acquired an energetic leader, Stefan Batory, who was supported by Russia's southern enemy, the Ottoman Empire. Ivan's realm was being squeezed by two of the time's great powers.
After rejecting peace proposals from his enemies, Ivan had found himself in a difficult position by 1579. The displaced refugees fleeing the war compounded the effects of the simultaneous drought, and the exacerbated war engendered epidemics causing much loss of life.
Batory then launched a series of offensives against Muscovy in the campaign seasons of 1579–81 to try to cut the Kingdom of Livonia from Muscovy. During his first offensive in 1579, he retook Polotsk with 22,000 men. During the second, in 1580, he took Velikie Luki with a 29,000-strong force. Finally, he began the Siege of Pskov in 1581 with a 100,000-strong army. Narva, in Estonia, was reconquered by Sweden in 1581.
Unlike Sweden and Poland, Frederick II of Denmark had trouble continuing the fight against Muscovy. He came to an agreement with John III of Sweden in 1580 to transfer the Danish titles of Livonia to John III. Muscovy recognised Polish–Lithuanian control of Livonia only in 1582. After Magnus von Lyffland, the brother of Fredrick II and a former ally of Ivan, died in 1583, Poland invaded his territories in the Duchy of Courland, and Frederick II decided to sell his rights of inheritance. Except for the island of Saaremaa, Denmark had left Livonia by 1585.