An EU court ruling had ordered the Hungarian government to suspend a law that allows police to deport or physically "push back" asylum-seekers across the Serbian border.
Hungary's constitutional court has struck down a bid by Prime Minister Viktor Orban's government to challenge a ruling by the EU's top court against Budapest's harsh asylum policy.
The petition by Justice Minister Judit Varga "cannot be the subject of a review of the ECJ judgment," nor can it lead to an "examination of the primacy of EU law", the Hungarian court said on Friday.
But it said that in areas of joint legal jurisdiction between Brussels and Hungary, Budapest has the right "to ensure the effectiveness of the joint exercise of competences".
The ruling on Friday was a "milestone decision", Varga said afterwards in a Facebook message.
It meant that Budapest can "adjust its national rules to reality by adopting additional, unique measures," she said.
"With this judgment, the constitutional court has built a strong legal barrier in addition to the physical closure of our borders," she said, referring to the border fence along Hungary's southern frontiers.
'Attempt at sobotaging' ECJ ruling?
But rights group the Hungarian Helsinki Committee hailed the constitutional court ruling.
Budapest's "attempt at sabotaging the ECJ ruling judgment has failed, the Constitutional Court refused to question the primacy of EU law," it said in a statement.
"No green light to disregard ECJ rulings, no more excuses, pushbacks must end now," it said.
Budapest had asked the court earlier this year to review a ruling from the European Court of Justice ordering it to suspend a law that allows police to deport or physically "push back" asylum-seekers across the Serbian border.
Last month, during a trip to Budapest, EU Justice Commissioner Didier Reynders said that challenges to ECJ ruling were "unacceptable".
The Hungarian move mirrored a Polish constitutional court ruling in October that challenged EU law and plunged the bloc into crisis.
Orban later signed a government resolution in support of Warsaw that called on EU institutions to respect the sovereignty of the bloc's 27 member countries.
"The primacy of EU law should only apply in areas where the EU has competence, and the framework for this is laid down in the EU's founding treaties," the constitutional court said.
National law-enforcement bodies, in particular constitutional courts and tribunals, have the right to examine the scope and limits of EU competencies, it said.
Budapest, like its Warsaw ally, has long been engaged in tussles with Brussels over legislation targeting LGBTQ people, independent media and civil society.