WARSAW — Europe's troublemaker is changing its tune.

Since Poland's populist Law and Justice Party (PiS) came to power in 2015, the EU has struggled to get Warsaw to play by the rules. Diplomats complained the country was uninterested in cooperation, engaged in zero-sum thinking and had a total lack of understanding of how things are done in Brussels.

Now, with national elections coming up in October, Warsaw suddenly seems to want to play ball again.

In the power struggle for top EU jobs that followed May's European Parliament election, Poland's ruling party put aside its anti-German prejudice and backed the compromise candidate for the European Commission presidency, Ursula von der Leyen. Where just two years ago it had opposed the reelection of Donald Tusk as president of the European Council — denouncing him as a German puppet — Poland now championed the ex-German defense minister, one of Angela Merkel's closest allies, and even claimed to have played a pivotal role in assembling a majority in the European Parliament to support her.

If Poland's populist government is recalculating its position on the EU stage, one thing hasn't changed: its political priorities.

The ruling party was also conspicuously quiet when it came to one of its favorite anti-EU refrains: that Central and Eastern Europe are overlooked for key positions in the EU. Instead of raising its head over the parapet, PiS hardly made a fuss when none of the top jobs were awarded to candidates from the region. Even the rejection of PiS representatives as leaders of influential committees in the European Parliament provoked no more reaction out of Warsaw than a few raised eyebrows.

Well before the election, Poland was also remarkably constructive in the debate over the EU's strategic agenda for the next five years, undermining the widely held view of PiS as an agitator with negative views of the bloc's future. The government even signed a joint letter with France and Germany advocating for a more ambitious EU industrial policy — not an idea typically associated with the right-wing Euroskeptic party.

There are good reasons for Warsaw to want to change course. Negotiations over the next long-term EU budget are entering a crucial phase — and the stakes are high for Poland, which relies heavily on EU funds and faces the prospect that funding could be tied to a government's respect of the rule of law.

With Brexit looming large, Poland is also bracing for the bloc's center of gravity to move even further to the countries in the common currency area and knows it will have to fight to avoid being marginalized as a non-eurozone member.

But if Poland's populist government is recalculating its position on the EU stage, one thing hasn't changed: its political priorities.

For PiS, the top item on the agenda is not maximizing Poland's influence in the EU — or even maximizing the financial benefits to be gotten from the EU budget. The ruling party's most pressing political project is to consolidate its grip on the country's institutions.

Party leader Jarosław Kaczyński has said he wants to have "Budapest in Warsaw," and following Hungarian leader Viktor Orbán's lead has been a constant feature of PiS policy. If the party wins big in October's national election, Poland will set out even further down that path — no matter its overtures in Brussels.

The breakdown of the rule of law in Poland is progressing rapidly. On Tuesday, Deputy Justice Minister Łukasz Piebiak resigned after an investigative report published by Onet accused him of waging a smear campaign against judges opposed to the government’s judicial reforms. PiS has also refused to carry out a verdict from the Supreme Administration Court obliging it to publish — in the name of public interest — information about the nomination of members of a constitutional body, and is now planning a new reshuffle of the judiciary that would solidify the party's grip on the system. The government has also discussed the idea of "repolonizing" the media by limiting foreign investment in the private media sector and stepping in with state-controlled funds.

The EU is rightly concerned about the state of the rule of law in Poland and made the right call in launching a so-called Article 7 procedure and two infringement procedures against PiS over its judiciary reforms. In one of the cases — the forced retirement of Supreme Court judges — PiS has already had to back down.

The steps taken by the Commission represented a major change. Never before had the EU institutions treated issues related to a country's judiciary systems as something that was regulated by EU law, rather than a national competence.

It is this fundamental change that the PiS government has always opposed — and that is motivating its recent conciliatory approach on the EU stage.

Warsaw has learned to play the EU game in Brussels. Now the EU has to make sure it stays in control of the rules.

Yes, the ruling party's vision for Europe — what it calls a "Union of Nations 2.0" — contains constructive policy proposals that should be welcomed and debated. But these come hand in hand with an outright rejection of the Commission’s and the European Court of Justice’s right to intervene if sovereign nations states violate fundamental EU rules.

The new tone in PiS’s European policy is not a harbinger of a domestic policy change. Just the opposite: The shift is a calculated move to secure the government more room to manoeuvre domestically, and continue its illiberal project. The goal of this double approach — soft in European policy and tough at home — is to kill the Article 7 procedure and discourage the Commission from taking action on possible further rule of law violations.

Warsaw has learned to play the EU game in Brussels. Now the EU has to make sure it stays in control of the rules.

Piotr Buras is head of the Warsaw office of the European Council on Foreign Relations and a former non-resident fellow at the Institute for Human Sciences in Vienna working on rule of law in the EU.