During this time, Moldavia was invaded repeatedly by Crimean Tatars and, beginning in the 15th century, by the Turks. In 1538, the principality became a tributary to the Ottoman Empire, but it retained internal and partial external autonomy. Nonetheless, the Polish–Lithuanian Commonwealth continued to strongly influence Moldavia both through national politics as well as on the local level through significant intermarriage between Moldavian nobility and the Polish szlachta. When in May 1600, Michael the Brave removed Ieremia Movilă from Moldavia's throne by winning the battle of Bacău, briefly reuniting under his rule Moldavia, Wallachia, and Transylvania, a Polish army led by Jan Zamoyski drove the Wallachians from Moldavia. Zamoyski reinstalled Ieremia Movilă to the throne, who put the country under the vassalage of the Polish–Lithuanian Commonwealth. Moldavia finally returned to Ottoman vassalage in 1621.