A sub-lieutenant of the garrison, Vasily Mirovich, learned of his identity and formed a plan for freeing and proclaiming him Emperor. At midnight on 5 July 1764, Mirovich won over some of the garrison, arrested the commandant, Berednikov, and demanded the release of Ivan. His jailers, on orders of their commander, an officer surnamed Chekin, immediately murdered Ivan in compliance with the secret instructions already in their possession. Mirovich and his supporters were arrested and executed shortly thereafter. Ivan was buried quietly in the fortress, and his death secured Catherine II's position on the throne until her own son came of age.