In 1918, in the government of Prime Minister Nils Edén, Sandler became Secretary of State to the Minister of Finance, Fredrik Thorsson. He continued in the same capacity when Hjalmar Branting became Prime Minister in 1920. In 1921 when Thorsson went on to start the new Ministry of Trade, Sandler took his place as the Minister of Finance, a capacity he held until 1923. In Hjalmar Brantings second government, Sandler was a Minister without Portfolio, and in the third the Minister of Trade. He took the latter position after some persuasion, as he was intent to take up a job as the headmaster of the folk high school in Brunnsvik.
As Prime Minister
When Hjalmar Branting became ill and left office before his death in February 1925, and Fredrik Thorsson who was a likely candidate to replace Branting as Prime Minister also fell sick and died, Sandler was appointed Prime Minister, at the age of 41. As Prime Minister, Sandler had to deal with the issue of reducing the Swedish military, as had been promised during the election campaign. He was supported by the Freeminded People's Party in what became the largest disarmament in Sweden. Following disarmament, the issue of unemployment came into focus when the government annulled a decision by the Unemployment Commission to deny payment to workers at the Stripa mine who were on strike. The liberal and conservative parties, who held the majority seats in the Riksdag, disagreed with the government, called for a vote of no confidence, and defeated the government. The 1928 elections saw Arvid Lindman of the conservativeGeneral Electoral League becoming the Prime Minister.
Foreign affairs
Sandler returned to the government in 1932 as Minister of Foreign Affairs, a post he held until 1939. Sandler left the government over a disagreement with the Prime Minister about the Winter War. Sandler wanted Sweden to actively help Finland after the Soviet Union had attacked it on 30 November 1939, a stance the Prime Minister did not hold. Now a Member of Parliament, Sandler continued to be influential in Swedish foreign policy. In 1940 he became a member of the Standing Committee on Foreign Affairs, and the chairman from 1946 to 1964. He was also a United Nations Delegate.
Other achievements
Sandler was Governor of Gävleborg County. He was chairman of several governmental inquiries, including the Socialization Committee, a commission appointed to audit the Swedish refugee policy during World War II, known as the Sandler Commission, and the Commission on the Constitution. Sandler was one of the founders of The Workers' Enlightenment League in 1912. He was the main writer of the Marxist-oriented party programme of the Social Democratic Party in 1920. He published the widely circulated statistical outline of social classes "The society as it is". Between 1926 and 1932 he was director of Statistics Sweden. Sandler translated Das Kapital by Karl Marx into Swedish, and in 1943 he authored a book on literary and historic secret writings called Cipher.