Upon his return to Bavaria in June 1945, he served at the court in Munich. He became prime minister of Bavaria from 1945 to 1946, after the sudden dismissal of Fritz Schäffer, also holding the post of Minister of Justice until 1947. He became known at this time as the father of the new Bavarian constitution. After losing the December 1946 election, he was replaced as Bavarian prime minister by Hans Ehard but remained as Minister of Justice. When his party decided to leave the coalition with the Christian Social Union (CSU), he opposed this move and temporarily lost influence within the SPD, resigning from his ministerial post.