WARSAW Poland's general election on Sunday may propel a new nationalist-minded government into European politics, deepening divisions over the migration crisis and straining relations with Berlin, Brussels and Moscow.
The Eurosceptic Law and Justice party (PiS), led by former prime minister Jaroslaw Kaczynski, has toned down its anti-EU rhetoric since its first time in power in 2005-07, but diplomats in Brussels are worried that EU decision-making may soon be obstructed by a returning member of the awkward squad.
The staunchly conservative Kaczynski has nominated a less combative politician, Beata Szydlo, to be prime minister to lure disgruntled voters of the outgoing pro-European government.
But his deep distrust of big European powers, particularly Germany, remains intact and analysts say he is still expected to pull the strings.
"It may not be to the liking of everyone when you pursue your interests," said Witold Waszczykowski, a leading PiS foreign policy expert and deputy foreign minister in the previous PiS government. "But the EU is not an altruists' club."
With a more assertive Poland, the 28-member bloc will have a harder time dealing with Europe's largest refugee crisis since World War Two, negotiating a global deal on climate change and forging a united stance towards a resurgent Russia in the east.
In a parliamentary debate in September, Kaczynski said the pro-European government of Civic Platform had no right to take decisions on accepting migrants under foreign pressure because the decision may hurt the daily lives of Poles.
He later said refugees should be checked for diseases and parasites, a comment that drew accusations of using ultra-nationalist, fascist imagery to fan hatred and fear.
Prime Minister Ewa Kopacz ignored Kaczynski's warnings and made a deal with Brussels to take in about 7,000 refugees. With Kaczynski at the controls, that would not have happened.
PiS has made clear it does not want Poland to join the euro in the foreseeable future, until it reaches west European levels of prosperity. But Civic Platform was in no rush to join anyway.
The party supports an EU of strong nation states, making it a natural ally Eurosceptic Britain, but the two are likely to clash over the rights of Poles working in the United Kingdom to in-work and welfare benefits, which London wants to curb.
"Clearly there are things we share with (Prime Minister David) Cameron, mainly this push for a less bureaucratic, more cost-effective EU that does not seek deeper political integration," Waszczykowski said.
Poland will need EU cooperation to win new concessions for its highly-polluting coal sector, which PiS says is a pillar of the economy and of energy security.
While experts agree Warsaw has no choice but to transition from dependency on coal towards renewable sources of energy, the country may need more time and funds to switch to clean energy.
This could be tougher if Law and Justice antagonises Germany and other big European powers as it did in 2007 when Kaczynski invoked the number of Poles killed by the Nazis in World War Two to justify demands for greater voting power within the EU.
Jean-Claude Juncker, now president of the European Commission, told Kaczynski back then: "You will not be happy in the long-run if you are always looking in the rear view mirror."
During the last PiS-led government, Poland delayed the ratification of the EU's Lisbon treaty and blocked the launch of talks on a partnership pact with Russia.
Warsaw also needs cooperation from other EU member states to sustain sanctions on Russia over its annexation of Ukraine's Crimea peninsula and its role in destabilising eastern Ukraine.
Law and Justice is particularly hawkish on Russia following the 2010 crash of Poland's presidential jet in which Kaczynski's identical twin, Lech, who was head of state, died along with 95 other high-ranking officials affiliated with the party.
Jaroslaw Kaczynski has long argued that Russia bears at least partial responsibility for the crash in thick fog, and that his brother was probably assassinated.
Kaczynski has also said then-Polish Prime Minister Donald Tusk, who now chairs EU summits as president of the European Council, also bears some responsibility due to negligence. Moscow and Tusk strongly deny the accusations.
Relations between Tusk and a PiS government are likely to be frosty and tense.
Szydlo has taken a pragmatic and conciliatory policy stance during the campaign, but critics question how long that will last. They recall that Kaczynski sidelined the first PiS prime minister, Kazimierz Marcinkiewicz, after just nine months in 2006, taking the job himself.
"I do not believe in this change," said Jacek Kucharczyk, head of the Warsaw-based Institute of Public Affairs think-tank. "It seems to me that the temptation to resort to anti-German rhetoric will be strong."
Szydlo outlined the limits of her party's goodwill towards Berlin when she said in a debate on Tuesday that Poland should show conditional solidarity with the EU on migrants.
"If we are to show solidarity ... then why, I am asking, are people clinching deals behind Poland's back ... that hurt our interests?" she asked.
Together with other PiS politicians, she rallied against a deal between German power firms and Russian monopoly Gazprom to build another natural gas pipeline circumventing Poland.
The pipeline, called Nordstream II, embodies the worst fears of conservatives who see pacts between Poland's powerful neighbours, Germany and Russia, as an existential threat.
PiS-backed President Andrzej Duda has accused Germany of ignoring the legitimate economic interests of Poland and putting EU unity in question by signing the Nordsteam II deal.
A few weeks before Duda's maiden visit to Berlin in August, his top foreign policy aide laid out four conditions for Germany to maintain good relations with Poland.
Berlin should drop its opposition to NATO bases on Polish soil, he said, include Poland, NATO and the United States in the Ukraine peace talks that Germany and France have been conducting, agree to more concessions for Poland's coal sector and "respect the rights of Poles".
This marked a sharp departure from the style of both Tusk and Kopacz, who led Civic Platform governments in the last eight years and made every effort to keep good relations with Berlin.
"The foreign policy of PiS will be a function of internal policy," Kucharczyk said. "And in domestic policy sooner or later we will have a search for an enemy. Pro-Europeans will be in the crosshairs."
PiS' Waszczykowski said the party's image as anti-European and xenophobic was false and artificially created by Civic Platform and hostile media.
"We cannot damage the relationship with Germany in any way that would harm our economic interests. ... But there are themes where we clearly see things differently than Germany," he said.
(Additional reporting by Gabriela Baczynska and Wiktor Szary, Writing by Marcin Goettig; Editing by Paul Taylor)