Mardefelt was the son of Fieldmarshal Conrad Mardefelt. In 1702 during the Great Northern War, he was in charge of the operations of the Swedish Army in Western Poland and in 1704 he conquered Poznań. In 1706 he distinguished himself in the Battle of Fraustadt.