Around 25,000 people braved the rain in Munich on Sunday to protest the hard-line immigration stance of Chancellor Angela Merkel's Bavarian allies three months before they face a tough state election in Bavaria.

March organizers said in a statement they were demonstrating against the "irresponsible divisive politics" of top members of the Christian Social Union's (CSU) which governs Bavaria and is the sister party to Merkel's Christian Democrats (CDU).

They mentioned CSU leader and Interior Minister Horst Seehofer and CSU Bavarian state premier Markus Soeder and said they were taking a stand against a "politics of fear" and a societal shift to the right.

Seehofer's immigration stance nearly brought down Merkel's government earlier this month in a dispute over migration. By staking out a hard line, Seehofer is trying to bolster his party in the vote, in which the CSU faces a stiff challenge from the far-right.

Last week Seehofer deflected blame for the suicide of an Afghan man among a group deported to Kabul, after opponents called for his resignation for boasting that the deportations took place on his birthday.

The protest is another sign of the CSU's waning popularity after an Infratest poll published last week put its support in Bavaria at 38 percent, compared with the 47.7 percent it secured in a 2013 regional election.