Šarec tweeted he had ordered the closure to the health and interior affairs ministries and that the measure was in line with the agreement on joint and proportionate measures.
The government tweeted that the border would be closed as soon as technical and administrative conditions are met. "This is a necessary measure if we want to have the situation under control," Šarec later told the press.
"Italy has declared quarantine in the entire country but people are disregarding this and continue to leave Italy. It's high time we take action.
"In Primorska, a lot of people cross the border daily, we know that children [from Italy] are in kindergartens on this side of the border, for example."
Slovenia will strive to remain in the first phase of the spreading of the virus as long as possible, the government's official Twitter account also said, adding that cargo transport would not be limited so as not to cause damage to the economy.
The closure follows the ban on arrivals from Italy introduced a few hours earlier by Austria. The ban does not apply to Austrian citizens returning home and persons carrying a doctor's note certifying they are healthy. Also allowed is transit travel through Austria without stopovers.
Šarec said the measure – stepped up from what was being mentioned on Monday – had already been discussed at Monday's session of the National Security Council. The measures are adapting to the situation, which "is changing by the hour", he said.
While explaining individuals will be able to turn to the Slovenian Foreign Ministry for help, he said he had already stressed days ago people should avoid going abroad, especially to Italy.
The Slovenian Foreign Ministry expanded today its travel warning to the whole of Italy and advised Slovenians in Italy to return home.
Asked what will happen to those commuting to Italy for work, Šarec said the detailed explanations on this would follow shortly.
Meanwhile, in the afternoon, when the total reported number of confirmed case was still 31, the Health Ministry said almost 1,500 people had been tested.
It added the new cases were related to previously confirmed cases, explaining a total of 17 people had been infected abroad and 14 were the result of community transmission.
Measures for containing the spreading of the virus were stepped up in line with Monday's announcement. A ban is in place on indoor gatherings that include more than 100 people, which has affected most cultural events. There are a few exemptions to the ban, including shopping malls, weddings and funerals.
University lectures in large lecture halls have been cancelled for the next two weeks, while kindergartens and schools remain open for now.
Temperature screenings are expected to be introduced in the coming days at Ljubljana airport, which is seeing an increasing number of flight cancellations.
Meanwhile, fears of supply problems were assuaged today by Agriculture, Food and Forestry Minister Aleksandra Pivec, who stressed the supply of food products in Slovenia was not disrupted or in peril.