Egypt remained entirely Ottoman until 1867, except during French occupation from 1798 to 1801. Starting in 1867, Egypt became a nominally autonomous tributary state called the Khedivate of Egypt. However, Khedivate Egypt fell under British control in 1882 following the Anglo-Egyptian War. After the end of World War I and following the Egyptian revolution of 1919, the Kingdom of Egypt was established. While a "de jure" independent state, the United Kingdom retained control over foreign affairs, defense, and other matters. British occupation lasted until 1954, with the Anglo-Egyptian agreement of 1954.