Flemming participated in the Livonian campaign of the Great Northern War. His troops captured the fort Düna fort at Riga from the Swedes in 1700, renaming it "Augustenburg" ("August's fort"), but the Swedes defeated the allied Russian-Saxon army at the crossing of the Daugava in 1701. During the Battle of Kliszów in 1702 he was severely wounded.