Mary ruled together with her husband , William III and II . He became the ruler of both countries when she died in 1694 . Mary reigned jointly with her husband and first cousin , William III and II , who became sole ruler upon her death in 1694 .