Justice Minister Laszlo Trocsanyi said before the vote -- subsequently approved by 141 lawmakers with 41 against and one abstention -- that the case will be filed at European Court of Justice in Luxembourg in early December.
According to the text of the bill, the quota "ignores the (EU's) principle of subsidiarity and fails to grant national parliaments the opportunity to express their opinion".
"Most of Europe's population don't agree with the quota, its social legitimacy is lacking," Trocsanyi told reporters.
Slovakia has said it will also file a legal challenge against the plan, a key plank in the EU's strategy to deal with the influx of hundreds of thousands of migrants this year.
More From This Section
Poland's incoming European Affairs Minister Konrad Szymanski said Saturday that Warsaw no longer considered the plan as a "political possibility" after the Paris terror attacks.
Britain has exercised its opt-out on the scheme.
Hungary's Prime Minister Viktor Orban has long taken a hard line against the migrants, saying that the influx of so many Muslims poses a security threat and threatens the continent's Christian identity.
"We will decide who we want to let in who we want to live with, (the quota) doesn't make sense as it doesn't solve anything," he said.
Hungary has also built razor-wire and fence barriers on its borders with Serbia and Croatia after more than 400,000 migrants entered the country this year, diverting the flow through Slovenia into Austria.