In 1705 August made him general of the cavalry and Minister of War. At the Treaty of Altranstädt in 1706, Charles XII demanded of the deposed August the extradition of Flemming, arguing that he had estates in Swedish Pomerania and was therefore a Swedish citizen subject to Swedish law. Flemming relieved his Elector from this predicament by leaving for Prussia. When the Swedes left Poland in 1708 for their disastrous campaign in Russia (ending with the defeat at Poltava), the re-crowned August installed Flemming in the governor's residence in Dresden.