Chancellor Angela Merkel's centre-left opponents have won a narrow victory in polls in Germany's Lower Saxony state.
The Social Democrats and the Greens won a single-seat majority in the state, a region of eight million people in north-western Germany.
Mrs Merkel called the defeat "painful". It makes things difficult for her ahead of national polls in September, says the BBC's Steve Evans in Berlin.
The leader of Mrs Merkel's coalition partner offered to resign.
Mrs Merkel remains very popular in national polls, but she has suffered a series of setbacks in state polls as she aims for a third term as chancellor.
Although her conservative CDU party won the most votes in Lower Saxony, it will be unable to govern with its coalition partner, the liberal FDP.
Sunday night's knife-edge finish saw the CDU take 36%, with the FDP taking nearly 10%.
They were pipped by the Social Democrat SPD and the Greens, who took 33% and 14% respectively.
"Of course when you have been on such an emotional rollercoaster then a defeat is that much more painful," Mrs Merkel said afterwards.
The Social Democrats' leader, Peer Steinbrueck, said: "It shows the race until September is far from over."
The result also swings the Bundesrat upper house of parliament - which is based on representation from the German states (Laender) - in favour of the opposition, meaning it can block legislation from the government and initiate laws itself.
Although the FDP performed much better than expected, doubling poll forecasts, this was thought largely due to the fact that some CDU supporters split their two-vote ballot in an effort to save the coalition.
Party leader Philipp Roesler, who is also Mrs Merkel's economy minister and vice-chancellor, said soon after the result: "It is a great day for the FDP in Lower Saxony but it is also a great day for the FDP and liberals in Germany as a whole."
But within hours he had offered to hand over the party leadership to his main rival, veteran Rainer Bruederle.
That offer was rejected by the party, but it was nevertheless agreed that Mr Bruederle would be its main candidate in September.
The party has lost support dramatically since entering into coalition with the CDU in 2009.
Analysts believe Mrs Merkel can probably remain chancellor after the national election, but may have to ditch the FDP and form a coalition with the SPD instead.
David McAllister, the incumbent leader of Lower Saxony's government and close ally of Chancellor Merkel, had been hoping for re-election.
He was born in Berlin to a German mother and a Scottish father and has been seen as a possible successor to Chancellor Merkel as CDU leader.