He was the son of Franz von Werner, a Croatian landowner of Austro-German origin, and his wife, the former Eleonore Pfeiffer. After completing high school he joined an Austrian cavalry regiment. During the Russo-Turkish Crimean War he became an officer in the Turkish Army, converting to Islam.
