The Second Treaty of Thorn (October 19, 1466) ended the Thirteen Years War or "War of the Cities", between Poland and Teutonic Knights and which had begun with the revolt (February 1454) of the Prussian Confederation led by the cities of Danzig, Elbing and Thorn (now Gdansk, Elblag and Torun) and gentry against the rule of the Teutonic Knights.

The Treaty partitioned the defeated Teutonic Order's territory in the land then known as Prussia. The Order acknowledged the rights of Polish crown to rule over Prussia's western half (subsequently known as Polish or Royal Prussia).

The Order retained control of eastern Prussia under the overlordship of the Polish king, but lost this territory also in 1525, when its Grand Master Albert of Brandenburg adopted Lutheranism and assumed the title of Duke as hereditary ruler under overlordship of Poland (see the Prussian Tribute), the area subsequently being known as Ducal Prussia.

See also The First Treaty of Torun