POLAND is one of the European Union’s biggest success stories. Since it joined the EU in 2004 its GDP per head has almost doubled. Poles are more likely to be fond of Brussels than most other big members of the club. But since Poland’s new government, led by the populist Law and Justice party (PiS), came into power on November 16th, the cosy relationship between Poland and the rest of Europe is in danger. Increasingly, the poster child for European integration seems more like a moody teenager.

Much of PiS’s success can be explained by the unpopularity of the previous government, led by Civic Platform (PO). After eight years of PO many Poles were fed up; the party was seen as careerist, aimless and out of touch. But PiS also broadened its appeal, running a campaign that made it appear far more moderate. Older, rural voters still make up the core of its support (see chart). But during the election it came first among 18-29 year olds too. And since winning the election in October with over 37% of the votes, its popularity has surged. One recent poll puts its support at 42%.

Since taking office PiS has dropped all pretence of moderation. Beata Szydlo, the prime minister, has little clout. The real power is in the hands of Jaroslaw Kaczynski, the party’s divisive leader (pictured above, with Ms Szydlo), who was prime minister during PiS’s incompetent term in government in 2005-7. Before the election Ms Szydlo pledged not to give the defence ministry to Antoni Macierewicz, one of the party’s kookiest conspiracy theorists. (Like many in PiS, he believes that a 2010 plane crash that killed Mr Kaczynski’s brother Lech, Poland’s president at the time, was a Russian plot, and that a government investigation that found it was an accident was a cover-up.) Nevertheless Mr Macierewicz, a longtime crony of Mr Kaczynski, was made minister of defence. The government now says it will reopen the investigation into the crash.

PiS is consolidating its control over other levers of power, too. It has sacked the heads of the security and intelligence services and put in its own men. It annulled the appointment of five constitutional judges approved under PO and substituted ideological allies, disregarding a court that warned the move may be unconstitutional. Andrzej Duda, the president, pardoned Mariusz Kaminski, a friend of Mr Kaczynski sentenced to three years in jail for abuse of power when he headed an anti-corruption bureau. He now has the even more powerful job of intelligence co-ordinator. The new culture minister tried to axe a highbrow theatre production featuring onstage nudity; a state TV journalist who pressed him about the botched decision was briefly suspended.

Such domestic developments are troubling, but the government’s attitude to Europe and foreign policy appears to be worse. The morning after the attacks in Paris, its minister for Europe wrote an editorial pronouncing the hard-won EU agreement to distribute migrants among member states to be a dead letter. Ms Szydlo has backed off that stance but still seems unable to commit to the refugee scheme; in an interview, she was optimistic that Europe would now take a more “rational” approach to the migrant crisis. The government has mooted cancelling defence contracts with French and American companies, preferring ones which use factories in Poland. PiS has redoubled Poland’s opposition to Europe’s climate policies; 85% of Polish electricity already comes from coal-fired power plants, yet the new government obstinately vows to build even more.

This all threatens Poland’s international credibility, says Piotr Buras of the European Council on Foreign Relations, a think-tank. After eight years in opposition, most PiS politicians have few international contacts. Besides, the government is more concerned with domestic matters. Ms Szydlo plans to start paying parents monthly child benefits, increase the standard tax deduction, and lower the retirement age to 60 for women and 65 for men. Those over 75 will get free medication, and the state healthcare budget will be boosted.

While PiS’s denunciations of immigrants draw headlines, it is the economic policies that its voters really care about. In Lublin, a poor town in Poland’s agricultural east that is a stronghold of PiS support, a party activist does mention the fight against “genderisation”, the party’s catch-all term for feminism and gay and transgender rights. But among local voters, the talk is all of scant pensions and low wages.

How the new social policies will be funded is unclear. The changes, especially on pensions, are very costly. Proposed taxes on banks and supermarkets cover only a fraction of their cost, according to Polityka Insight, a think-tank. The budget deficit could hit 4% of GDP next year. With an ageing population and many young people leaving for elsewhere in the EU, lowering the retirement age seems disastrous.

European diplomats are publicly taking a restrained approach to Poland’s new government. Privately, many are worried. The productive Polish-German relationship could break down over migrants. To judge by its previous term, PiS may grow wilder with time rather than tamer. What is certain is that Europe has a new awkward country to deal with.