The cabinet of 16 ministers, including two without portfolio, was backed by 45 votes to 34 in a secret ballot after a nine-hour debate in which the newly formed opposition and coalition exchanged blows.
Addressing reporters after the vote, Marjan Šarec dismissed the criticism: "My cabinet is trustworthy. We have linked experience with a measure of enthusiasm, naivety perhaps, but it's how it should be."
He said his government would get down to work right away. "There have been many words, maybe too many, now the time has come to start working," he said, adding that they would be judged by their achievements.
The government's priorities will be healthcare, the economy and the defence and security system. "These are the topics that keep most of Europe busy. We'll get down to those right away."
His first trip abroad as PM will be to Salzburg, Austria, next week to attend an informal meeting of EU leaders. "My first bilateral meeting is likely to be in Brussels, after which I plan to visit neighbouring countries."
The coalition of the centrist Marjan Šarec List, Modern Centre Party, Alenka Bratušek Party, Pensioners' Party, and the centre-left Social Democrats, only has 43 of the 90 seats in parliament.
However, the coalition signed a partnership deal with the Left, which pledged that its nine MPs would not oppose the cabinet's appointment.
In the vote, the Šarec cabinet was backed by coalition MPs, as well as the two MPs representing the Italian and Hungarian minorities. The Left abstained.
Forming the new opposition, the Democratic Party (SDS), New Slovenia and National Party voted against.
SDS leader Janez Janša, who was not able to form a coalition despite his party winning the 3 June election, issued an acrimonious attack on the Šarec cabinet.
He said that leading a coalition of "six parties, one of which with supra-coalition status" would be a nightmare for Šarec and that each day under such a government would be a day lost for Slovenia.
He described the new cabinet as "a recycled version of what we were watching in the last four years", which he said was also reflected in copy-pasted sections of the coalition agreement.
"What worries are the spices added to this dish, but also what is missing," said Janša, pointing to measures to deal with demographic trends and tackle bureaucracy and corruption.
Meanwhile, Matej Vatovec from the Left said the party would watch the minority government closely to make sure it honoured the promises given in exchange for their support.
In his address to parliament before the vote, Šarec acknowledged that his government would have a lot on its plate, but he pledged to be pro-business and to balance the demands of the public and private sector.
Šarec dedicated a significant portion of his speech to business, in particular allegations by business in recent weeks that the government would hike up corporate taxes.
"There has been a lot - too much - talk in recent days, before the government even took office, about taxes and the economy in the sense that this government will destroy business initiative and create a Venezuela. Never!" he said.
The government formation process took more than three months. Šarec, whose party came second in the election, first attempted to build a coalition of five centrist parties plus the conservative NSi.
After the latter withdrew, the Left from the opposite side of the political spectrum was invited to join in, but eventually the party opted for a project partnership with the coalition.
The cabinet includes two former prime ministers, Miro Cerar and Alenka Bratušek, four former ministers and three former state secretaries. Only four of the 16 ministers are women.
Together with the prime minister, who served two terms as mayor of Kamnik before being elected MP in June, the cabinet includes two former mayors and four jurists.
The government includes all coalition party leaders, bar SocDem leader Dejan Židan, who was appointed speaker of the National Assembly.
At the age of 40, Šarec took over as Slovenia's youngest prime minister. A former comedian, he became a sensation in national politics after forcing incumbent Borut Pahor into a run-off in the 2017 presidential election.
Rok Čakš, the editor of the conservative news portal Domovina, said the biggest challenge for Šarec would be keeping his coalition partners in check, balancing a variety of opposing interests, and managing the partnership with the Left.
Political analyst Aljaž Pengov Bitenc said that the first real challenge would be health reform as well as trying to strike a balance between social security and businesses.
The biggest test will come from what Pengov Bitenc termed "external factors", such as the migration crisis or an economic crisis, a worsening of relations with neighbouring countries or reforms at European level. Since such challenges require a great deal of "statecraft wisdom", they will show "what Šarec is made of".