In 1918, after the dissolution of the Austro-Hungarian Empire and the creation of Yugoslavia, he became a legal advisor to the temporary Provincial Government for Slovenia in matters of welfare and social policy.
In 1922, he was the co-founder of the Alliance of the Working People, a wide left wing platform that unified several political parties, from Christian Socialist groups to Communists, for the local elections.
In 1929, he was appointed to the State Legislative Council, an institution established during the royal dictatorship of Alexander I of Yugoslavia as a substitute for an elected parliament.
By the early 1930s, his theories came under attack from all sides: from the right, he was challenged by the corporativist Catholics around Ernest Tomec, Lambert Ehrlich and Josip Jeraj.
In the last years before the Second World War, Gosar moved to a more centrist position, calling for a Christian Democratic re-alignment of the Slovene People's Party.
Rejecting both the partisan movement and the collaborationist Slovene Home Guard, he became one of the leaders of the so-called "Catholic Centre", together with Jakob Šolar in the Province of Ljubljana, and Engelbert Besednjak and Virgil Šček in the Julian March.
After the return in 1945, he was stripped of most of his pre-war academic functions by the new Communist regime; he was however allowed to continue teaching forest legislation at the Technical Faculty.