|By Justyna Pawlak and Wojciech Strupczewski

|By Justyna Pawlak and Wojciech Strupczewski

KRYNICA-ZDROJ, Poland (Reuters) - Viktor Orban, Hungary's fiery nationalist prime minister, is known for the contempt he showers on most European leaders. But when he appeared alongside Poland's Jaroslaw Kaczynski last week, he paid his fellow Eastern European right-wing ruling party leader the ultimate complement: together they would make perfect partners in crime.

"The saying goes that if you trust someone, you can steal horses together," Orban said at the debate at a Polish mountain resort. "The Hungarians will gladly steal horses with the Poles."

Since he took power in 2010, Orban, 53, has been Europe's unruly nationalist step-child, inviting strong criticism from Brussels and from fellow European leaders for his anti-immigrant views and his determination to consolidate power in the hands of his ruling Fidesz party.

But since last year, when neighboring Poland elected Kaczynski's right-wing Law and Justice Party (PiS), Orban has had a friend at last.

Now, with Britain having voted to leave the EU, after a campaign built on many of the same criticisms of Brussels that Orban and Kaczynski have long embraced, the two leaders say they have been vindicated. At a summit in Bratislava later this week, Poland and Hungary plan to lead a call for Brussels to return more powers to EU member states.

"There is a new identity, a European identity emerging ... the Brits said 'no' to it," Orban said to Kaczynski, who applauded, during last week's debate at the ski resort of Krynica-Zdroj in the Carpathian Mountains. "Now Europe is being forced to face up to its mistakes ... and, we, the central Europeans can launch the transformation."

"DICTATOR"

That puts them on a collision course with European figures who, despite the British vote to leave, still see greater cooperation among the EU's remaining members as the solution to its problems, from the euro zone financial crisis to immigration.

Jean-Claude Juncker, the European Commission president who was once caught on an open microphone jokingly greeting Orban as "Dictator" at a summit meeting, defended the EU's principle of "ever closer union" in an annual address on Wednesday.

"The scope in which we cooperate together is far too small," Juncker said. "Far too often national interests are brought to the fore."

He may have had Orban and Kaczynski in mind when he spoke out against populist political movements: "Populism doesn't solve problems. Populism creates problems, and we have to be aware of that and protect ourselves against it," Juncker said.

Orban has made contempt for Brussels the centerpiece of his rhetoric, particularly in the field of immigration.

Hungary became the main route by which hundreds of thousands of refugees and migrants arrived over land into Europe's border-free Schengen zone in the past two years, although nearly all of them passed on to other destinations without staying.

While German Chancellor Angela Merkel said Europe had a moral duty to welcome refugees, Orban built a wall on the frontier to keep them out.

His government has campaigned against an EU plan to spread some of the burden by requiring member states to accept quotas. Although the plan would settle only around 1,300 refugees in Hungary, he calls it a threat to Hungary's way of life.

Hungary is fighting the plan in court, and Orban called a referendum next month at which voters are expected overwhelmingly to back the government and reject any future EU migrant quotas.

It is hardly the first time Orban has tangled with Brussels, which for years has objected to laws he has passed to curb the independence of the media, central bank and courts.

Meanwhile, since taking power last year, Kaczynski's PiS has proposed similar measures in Poland, prompting Brussels to threaten to impose financial sanctions. Orban vows to use Hungary's vote in Brussels to veto any attempt to punish his Polish friends.

The planned Polish moves have prompted many to say that Kaczynski's PiS is now copying from Orban's playbook. At the event in the mountain resort alongside Kaczynski, 14 years his senior, Orban humbly insisted it was the other way around.

"It's not fair to say that," he said of the suggestion Kaczynski was copying him. "Chairman Kaczynski is much more experienced ... It was the Hungarians who were always peeking at what the Poles were doing."

An alliance between Fidesz and PiS is likely to further antagonize Brussels and Berlin.

"Saying that you can steal horses together is not constructive and can fuel conflict within the EU, which will benefit Russia," said Cornelius Ochmann, managing director at the Foundation for Polish-German Cooperation, set up by the two countries' governments in the 1990s to promote joint projects.

Orban's Fidesz and Kaczynski's PiS aim to unveil their demands to curb the powers of Brussels at an EU summit on Friday in Bratislava, as an initiative by the "Visegrad states" -- Poland, Hungary, and neighbors Slovakia and the Czech Republic.

Kaczynski's party protege, Polish Prime Minister Beata Szydlo, says the four ex-Communist states, which joined the EU together in 2004, would present a common "prescription" to solve the bloc's woes by transferring power back to member states.

However, many in Europe say it is still too early to envision Orban and Kaczynski at the helm of a broader European movement to curtail the EU.

Although the Czech Republic and Slovakia share Poland's and Hungary's opposition to the refugee relocation plan, they are both considerably less gung ho in their overall euro-scepticism than either Warsaw or Budapest.

Friday's summit will show how far Kaczynski and Orban can persuade neighbors to follow them, said Michael Leigh, senior fellow at the German Marshall Fund.

"It will be a litmus test to see to what extent the kind of rhetorical positions ... could lead to concrete cooperation on specific issues ... that could change the course of EU affairs," he said. "I rather doubt it."

(Additional reporting by Maria Wejcman and Pawel Sobczak in Warsaw, Jan Lopatka in Prague and Krisztina Than in Budapest; editing by Peter Graff)