Throughout this time , Estonia was a part of the Russian Empire , however Germany then annexed the region during the First World War ; when the German army eventually retreated in 1918 , Estonian forces prevented Russia from re-taking the area in the Estonian War of Independence , and an independent Estonian Republic was gradually established between 1918 and 1920 .