In the final days of World War I, as Germany's military situation collapsed, Kaiser Wilhelm II abdicated after thirty years of rule, ending the German Empire and beginning Germany's life as a republic. Although his departure may seem obvious after defeat, a large majority of the country's upper class would have preferred he stay, and he retained good popularity among the people.