When the Second Northern War broke out in 1654, Charles X Gustav of Sweden offered an alliance to Frederick William I, the "Great Elector" of Brandenburg and duke of Prussia.
As the price for this alliance would have been the surrender of the Prussian ports of Pillau (now Baltiysk) and Memel (now Klaipėda) to Sweden, Frederick William I refused and instead signed a defensive alliance with the Dutch Republic in 1655.

Following Swedish military successes, including an invasion of Prussia, Frederick William I was forced to take Prussia as a fief from the Swedish king in the Treaty of Königsberg on 7 January (O.S.) / 17 January (N.S.) 1656.
Before, Frederick William I had held that duchy as a fief of the Polish king.
In Königsberg, the "Great Elector" further had to meet the Swedish demands for Pillau and Memel, promise financial and military aid, and surrender half of the port duties to Sweden.

On 15 June (O.S.) / 25 June (N.S.) 1656, Charles X Gustav and Frederick William I concluded a formal alliance in the Treaty of Marienburg after Swedish advances in the Polish-Lithuanian Commonwealth had stalled.
Sweden offered conquered Polish territories, and Frederick William I went to support Charles X Gustav with his newly formed army in the Battle of Warsaw on 28–30 July, which marked "the beginning of Prussian military history".

Though victorious, the subsequent entry into the war of the Russian tsar, the Holy Roman Emperor and the Dutch navy left Sweden in an unfavourable condition, and dependent on further Brandenburgian support.
This enabled Frederick William I to raise the price for remaining a Swedish ally, and Charles X Gustav met his demands in the treaty of Labiau.
When the Second Northern War broke out in 1654, Charles X Gustav of Sweden offered an alliance to Frederick William I, the "Great Elector" of Brandenburg and duke of Prussia. As the price for this alliance would have been the surrender of the Prussian ports of Pillau (now Baltiysk) and Memel (now Klaipėda) to Sweden, Frederick William I refused and instead signed a defensive alliance with the Dutch Republic in 1655.
Following Swedish military successes, including an invasion of Prussia, Frederick William I was forced to take Prussia as a fief from the Swedish king in the Treaty of Königsberg on 7 January (O.S.) / 17 January (N.S.) 1656. Before, Frederick William I had held that duchy as a fief of the Polish king. In Königsberg, the "Great Elector" further had to meet the Swedish demands for Pillau and Memel, promise financial and military aid, and surrender half of the port duties to Sweden.
On 15 June (O.S.) / 25 June (N.S.) 1656, Charles X Gustav and Frederick William I concluded a formal alliance in the Treaty of Marienburg after Swedish advances in the Polish-Lithuanian Commonwealth had stalled. Sweden offered conquered Polish territories, and Frederick William I went to support Charles X Gustav with his newly formed army in the Battle of Warsaw on 28–30 July, which marked "the beginning of Prussian military history".
Though victorious, the subsequent entry into the war of the Russian tsar, the Holy Roman Emperor and the Dutch navy left Sweden in an unfavourable condition, and dependent on further Brandenburgian support. This enabled Frederick William I to raise the price for remaining a Swedish ally, and Charles X Gustav met his demands in the treaty of Labiau.
Treaty of Labiau