Angela Merkel's sister party has suffered huge losses in Bavaria's state elections, provisional results suggest, in a blow to the German chancellor.

The CSU is set to lose its absolute majority in the state parliament.

The Greens surged into second place and the anti-immigration AfD entered the state parliament for the first time.

The CSU has ruled Bavaria almost single-handedly since 1957, but has lost support as opinion becomes polarised over issues like migration.

Party leader Horst Seehofer said it was "not a nice day", but added it was only "one side of the coin" as the vote gives "a clear mandate" allowing the CSU to form a new government.

Preliminary official results showed the CSU (Christian Social Union) won about 37% of the vote, down 10 points on four years ago, with the left-leaning pro-immigration Greens on 18%.

The Alternative for Germany (AfD) came fourth with 10%, behind a collective of independent candidates known as the Free Voters.

Mrs Merkel's national coalition partners, the centre-left Social Democrats (SPD), trailed in fifth with less than 10%, their vote halved.

There is speculation that it could pull out of the government in an attempt to survive as a party.

Its leader Andrea Nahles, blamed the poor performance in Bavaria on squabbling within the coalition.

What happened to the CSU?

The AfD's success in Bavaria has not been as great as in eastern Germany, but it appears to have taken large numbers of votes from the CSU.

But by echoing some of the AfD's hardline policies such as on migration, the CSU also seems to have lost the support of more moderate voters.

The CSU's Markus Söder, current Bavarian prime minister, said the projected result was painful but the party should learn from it.

"We have to analyse the changes taking place both in Bavaria and in society," he said.

"One of the most important jobs we now have is to ensure that this state is stable, governable, and remains as strong as it is now."

Bavaria key facts
Nearly 13 million residents and the biggest by area of Germany's 16 federal states

Capital Munich is Germany's third-largest city, after Berlin and Hamburg

Second-highest GDP out of 16 German states

Historically conservative region, with strong Catholic and local traditions

Industrial powerhouse: car and IT sectors especially strong, rich in family-run firms

What is the bigger picture?
The poll is a serious setback for Mrs Merkel, just months after she formed a fragile coalition with the CSU and SPD - both of whom suffered huge losses in Bavaria.

The BBC's Jenny Hill in Bavaria says the election illustrates the complexity of the challenge faced by so many of Europe's large established parties.

It's not simply the rise of the far right, she says, but that voters are walking away in favour of smaller, newer movements.