Theresa May flew in to Warsaw today at a rather inconvenient moment – just one day after the European Commission launched an unprecedented legal process against a government that the British prime minister has been cultivating as a useful partner during the Brexit negotiations.

Yet, while the British Government is keen to enlist Polish support in seeking better Brexit terms, and to have a long-term ally within the EU once the UK leaves, from Poland’s perspective the aims are rather different, and sometimes contradictory.

Indeed, the Polish government has made clear it would prefer for Brexit not to be happening at all. Its foreign minister stirred anger in British tabloids last year when he said that “it is in our interest that Britain remain an EU state as long as possible and pays contributions as long as possible,” a refrain he has since repeated.

His words reflect concern in Poland, the biggest net recipient of EU funds, about the departure of one of the biggest net contributors. The City of London’s envoy to the EU recently complained that the Polish government has a “myopic obsession with the size of Britain’s exit fee”.

Theresa May announces new security treaty with Poland

There is already talk in Brussels of reducing Poland’s share of the next EU budget, perhaps by linking parts of it to respect for the rule of law or willingness to accept refugee quotas – both issues on which Law and Justice (PiS) has been in conflict with Brussels. Brexit provides a useful pretext to further justify budgetary cutbacks.

It will also mean that the ruling national-conservative PiS party loses its most important EU ally. The Tories and PiS are by far the largest members of the European Conservatives and Reformists (ECR) grouping in the European Parliament, together making up almost half its MEPs. Once the UK leaves, PiS will be left as the only major party in a minute, motley and marginal faction.

PiS also fears that the loss of the eurosceptic UK will give the likes of France and Germany greater licence to push ahead with moves towards a more tightly integrated EU core, the kind of “two-speed Europe” that the Polish government has made clear it would find unacceptable.

The Poles have at times been frustrated by a perceived lack of support from Britain in their various conflicts with the EU. When PiS was embarrassingly defeated in its bumbled attempts to stop Donald Tusk, a domestic political rival, being reappointed as president of the European Council, the Polish foreign minister angrily asked, “Where was the UK?” during the discussions. As an EU diplomat noted at the time, it was a “lose-lose situation for Britain: either Mrs May alienates almost all the other member states or she upsets the Poles, who she’s spent months and months cultivating.”

At other times, however, the Conservatives have voiced support for PiS at EU institutions. The chairman of the ECR, Tory MEP Syed Kamall, has hit out against the EU for “ganging up on the democratically elected government of Poland”. This has created the bizarre sight of one of Britain’s most senior Muslim politicians defending a government that deliberately stokes anti-Muslim sentiment. PiS’s vice-president of the European Parliament, for example, says that Poland must “learn from the mistakes of other” countries, who have foolishly “allowed in Muslim immigrants” (such as Kamall’s family, presumably).

Such episodes highlight the tricky balancing act May is facing in securing Poland as an ally while also avoiding offending other parties to the Brexit negotiations, many of whom want to see the Polish government sidelined for its actions over the rule of law, refugees, logging in the ancient Białowieża Forest and a host of other alleged infractions.

Following yesterday’s announcement that Article Seven proceedings have been launched against Poland, May’s spokesman was forced to acknowledge that the Prime Minister would “raise her concerns” over “respect for the rule of law” while in Warsaw. However, after the summit had concluded, May told a press conference that this was an internal matter for Poland to deal with alone. The agenda instead focused on the Polish government’s priority of obtaining British support in defending against the threat of Russia.

A more telling test will come when, at the next stages of the Article Seven process, the UK and other member states are required to vote on whether to proceed. Then, once again, we will see how Theresa May’s dealings with Warsaw represent yet another moving part in the complex machinery of the Brexit process.