Georg Friedrich Graf von Hertling (31 August 1843 – 4 January 1919) was German Bavarian politician. He served as Minister-President of Bavaria 1912–1917 and then as Minister-President of Prussia and Chancellor of the German Empire from 1917 to 1918 under Kaiser Wilhelm II during World War 1 until in 1918 when became the Weimar Republic .