During the Hungarian revolution of 1848, when Hungary tried to gain independence from Austria, Rijeka was captured by the Croatian troops (loyal to Austria) commanded by Ban Josip Jelačić. The city was then annexed directly to Croatia, although it did keep a degree of autonomy. Rijeka was returned to direct Hungarian rule in 1868 with the Croatian–Hungarian Settlement agreement, renewing its status as "corpus separatum" (Hungarian "island" within Croatia). The city's position was defined with a separate annex to the settlement agreement, the so called "Rijeka patch" ("Riječka krpica" in Croatian).