A government spokesman said Budapest had taken the step because "migrants appeared" on the Slovenian side of the border.
Slovenia, a small country of two million people, says it can accommodate up to 8,000 migrants per day. Both Ljubljana and Zagreb say they will not restrict the flow so long as Austria and Germany keep their doors open.
Hungary says it is duty-bound to secure the borders of the European Union from mainly Muslim migrants threatening, it says, the prosperity, security and "Christian values" of Europe.
Budapest is among several ex-Communist members of the EU that oppose an EU plan to share out 120,000 refugees among its members. That is only a small proportion of the 700,000 migrants expected to reach Europe's shores by boat and dinghy from North Africa and Turkey this year, many of them fleeing war and poverty in the Middle East, Africa and Asia.
At a summit in Brussels on Thursday, the EU offered Turkey a possible three billion euros ($3.4 billion) in aid and the prospect of easier travel visas and "re-energised" talks on joining the bloc if it would help stem the flow of migrants across its territory.
But Hungary said this fell short of Budapest's demands, which include formation of a common force to protect the borders of Greece, where most migrants arrive across the Aegean Sea from Turkey before heading north through Macedonia and Serbia.
Asked what would happen if Germany was to close its doors, Croatia's interior minister warned of a "domino effect".