"Irrespective of who voted for me today and who voted against, all can rest assured that I will be working for the benefit of everyone," Šarec said as he was sworn in.
He noted that he had gotten more votes than expected - the five coalition parties have 43 MPs in the 90-member parliament, the Left has nine, while he could also count on the support of the two MPs representing the Hungarian and Italian minority.
The 40-year-old Kamnik mayor, whose Marjan Šarec List (LMŠ) came second in the 3 June general election, has become the 9th prime minister in independent Slovenia.
If he manages to form a government, consisting of the LMŠ, the SocDems, the Modern Centre Party (SMC), the Pensioners' Party (DeSUS), and the Alenka Bratušek Party (SAB), this will be Slovenia's 13th government.
Šarec needs to put forward a list of candidates for the ministerial posts by 3 September. A vote on the candidates is scheduled in parliament for mid-September.
The Life of Marjan Šarec
In a short biography of the new PM, the STA notes that Šarec first made a name for himself as an imitator of senior Slovenian political figures. Having cast parody aside, he has now been given a mandate to form Slovenia's first minority government as the country's youngest prime minister.
A newcomer to national politics, the 40-year-old was serving out his second term as mayor of Kamnik as the party bearing his name won 13 of the 90 seats in the National Assembly to emerge as the second largest faction in the 3 June election.
The Marjan Šarec List (LMŠ), the party he founded four years ago to contest local election, shot up to the top of the polls after Šarec nearly defeated Borut Pahor in the run-off of the 2017 presidential election with 46.9% of the vote.
Heading into the presidential race as a complete outsider with no experience in national politics, Šarec outstripped the contenders of established parties and thwarted a widely expected walkover by the strongly favoured incumbent in the first run.
His presidential bid was not unlike his first foray into local government in 2010; mounting an independent bid for Kamnik mayor, he surprisingly defeated a favoured candidate and went on to win a second term in 2014 with 63% of the vote.
While his strong showing was in many ways a surprise for a political novice, his earlier career as a comedian on radio and TV, in particular a Friday variety show popular among the rural population, made him a household name in Slovenia.
Having obtained a university degree in acting in 2001, Šarec started working for public broadcaster RTV Slovenija and soon made a mark as a voice imitator on the broadcaster's flagship satirical show Radio Ga-Ga and its multiple TV offshoots.
He excelled as the voice of presidents Janez Drnovšek and Danilo Türk, the Democratic Party's (SDS) leader Janez Janša and the leader of the Pensioners' Party (DeSUS) Karl Erjavec.
He also developed one of the most popular fictional characters on modern prime-time TV, the blunt, salt-of-the-earth farmer Ivan Serpentinšek, a grumpy and misogynistic old man with a penchant for jokes about women.
Although he abandoned acting as soon as he became mayor, it remains hard for many to dissociate him from his stage persona and he has often been dismissed as a clown, a greenhorn, or at best as a populist offering simplistic solutions.
However, Šarec is dead serious about everything he does and he appears to have long been set on becoming a prime minister, even against the odds.
Despite ending as a runner-up, Šarec took an early initiative to form a coalition, inviting all parties bar the election winner, the Democratic Party (SDS), to enter into informal coalition talks.
His initial plan was to build a coalition with four other centre-left parties plus the conservative party New Slovenia (NSi). After the latter opted out, he was willing to accommodate the Left from the opposite side of the political spectrum.