BERLIN (AP) — Chancellor Angela Merkel vowed Monday to do more to restore Germans’ confidence in her unhappy coalition after a battering for both of her governing partners in Bavaria’s state election added to tensions in the alliance.

Sunday’s vote stripped Merkel’s conservative allies in Bavaria, the Christian Social Union, of their absolute majority in the state legislature for only the second time in 56 years. The center-left Social Democrats, Merkel’s other federal partner, slumped to a humiliating fifth-place finish in the wealthy state.

Both parties pinned much of the blame on the national government’s constant public infighting over migration and other issues since it took office in March.

“(The election) showed that even with the best economic data, with near-full employment in almost all parts of Bavaria, that isn’t enough for people when something is missing that is so important — confidence,” Merkel said.

Merkel’s Christian Democratic Union party wasn’t on the ballot Sunday, but an electoral challenge looms in two weeks as it defends its 19-year-hold on the governor’s office in Hesse, a central state that includes Frankfurt, on Oct. 28.

“My lesson from yesterday is that I, as chancellor of this ‘grand coalition,’ must do more to ensure that this confidence is there and that the results of our work are visible,” Merkel said. “And I will do that emphatically.”

The Social Democrats hope to win back Hesse but polls show them trailing and support for both parties is weak.

Sunday’s outcome rekindled speculation about whether the Social Democrats will leave Merkel’s federal government before its term ends in 2021. They only reluctantly joined Merkel’s coalition in March after a national election debacle last year.

Social Democrat leader Andrea Nahles brushed aside questions Monday about her party’s pain barrier.

“I don’t think that defining red lines is appropriate at this point,” she said. “Above all, we have an election in Hesse in two weeks in which we are now investing all our power. We are not going to waste our strength and time now on internal debates.”

As for the national government, “it is obvious that the whole style of our work together must change, and that hopefully was a message from this Bavarian election,” Nahles said.

Much of the blame for the squabbling has been pinned on the CSU leader, Interior Minister Horst Seehofer, who has continued a three-year feud over migration with Merkel. He nearly brought down the ruling coalition in June with a demand to turn back small numbers of asylum-seekers at the German-Austrian border.

Those tactics turned off Bavarian voters on both the right and left, and polls suggested that migration was some way down on voters’ list of priorities.

Seehofer appeared to have no intention of stepping down after his party received 37.2 percent of the vote, down from 47.7 percent five years ago, for its worst showing in Bavaria since 1950.

“I won’t hold a discussion about my position,” the 69-year-old said, insisting that his party still has “a special role in Germany’s political landscape.”

The big winners in Bavaria on Sunday were smaller parties. The environmentalist Greens came second while the far-right Alternative for Germany for the first time entered its 15th of Germany’s 16 state parliaments. A regional conservative party, the Free Voters, will likely become the CSU’s coalition partner in Bavaria.

“What’s happened in Bavaria is something that’s been the case in the rest of the country for some time: the weakening of major parties due to changes in society,” said Juergen Falter, a political science professor at the University of Mainz.

Bavaria has become more secular, weakening the CSU, while workers no longer automatically choose the Social Democrats, he said.

The CSU is likely to become “a bit tamer” in the national government because it has seen that constant infighting doesn’t help, Falter said. However, he expects the Social Democrats to try and make more of a mark — and possibly use a planned midterm evaluation next year to leave the federal government.

If that happens, Merkel, 64, could try to revive efforts aborted last year to form a government with the Greens and the pro-business Free Democrats, or Germany could head toward a new early election.

Merkel, Germany’s chancellor since 2005 and the leader of the CDU since 2000, has seen her authority weakened over recent months, but has indicated that she plans to seek another two-year term as party leader at a gathering in December.

A bad performance in Hesse could complicate those plans, but there’s no sign yet of a credible challenger.

“Merkel has no serious rivals,” Falter said. “None of those who might pose a risk to her have come out of cover.”