He attended cadet school in Rijeka and later joined Theresian Military Academy in Wiener Neustadt. Between 1869 and 1871 he attended Kreigsschule in Vienna and graduated with honors.
On 19 August 1866 he earned the rank of lieutenant of an infantry regiment. On 7 March 1909 he was named the commander of the 15th Corps stationed in Sarajevo, and at the same time Governor of Bosnia and Herzegovina. On 29 July of the same year, he was named the Chief Inspector of military troops.
Soon after, the command of the 15th Corps was handed over to Moritz von Auffenberg.
However, Varešanin remained the governor of Bosnia and Herzegovina, and it was for this reason that he was targeted by the Serbian underground liberation organization Black Hand. An unsuccessful assassination attempt was made on him on 10 June 1910, by Bogdan Žerajić, who fired five bullets from a revolver on Varešanin, and killed himself with sixth.
Žerajić"s assassination attempt was a big encouragement to Gavrilo Princip. Princip visited Žerajić"s grave where he promised to take a revenge, which he did by killing Archduke Franz Ferdinand in Sarajevo on 28 June 1914.
Even though assassination attempt was a failure, Varešanin started to think about his retirement.
On 10 May 1911 his request for dismissal as governor was accepted and he was replaced by Oskar Potiorek. On 10 July 1911 he officially entered into a retirement after 45 years of service.