BERLIN (Reuters) - Germany s Social Democrats vowed to return to the opposition and push themes of social justice as they remake their party after winning less than 21 percent of the vote in Sunday s election, the worst result in their post-war history. The SPD party swiftly announced it would quit the  grand coalition  in which it has served alongside conservative Prime Minister Angela Merkel for the past four years. Sunday s election gave Merkel a fourth term, but she faces difficult coalition talks after her own conservative bloc also won its smallest share of the vote since the 1940s. With nearly half of voters rejecting both of the main parties that have dominated Germany since World War Two, the SPD in particular faces a difficult task of winning back support. The party would  continue its fight for democracy, tolerance and respect  in opposition, leader Martin Schulz told cheering supporters, announcing the decision to pull out of the coalition.  We are the bulwark of democracy,  he said. Germany s oldest political party and one of the buttresses of the European left for 150 years, the SPD struggled to differentiate itself from Merkel s conservatives in coalition.  The SPD has been collateral damage of the dissatisfaction with the current government,  said Tyson Barker, an expert on German politics at the Aspen Institute.  It was not able to draw bright lines of opposition to Merkel s CDU and paid the price in lack of enthusiasm.  Tim Stuchtey of the Brandenburg Institute for Society and Security said he expected the SPD to move to the left after the election blowout, although he did not rule out the possibility it could change its mind about a coalition and return without Schulz if Merkel fails to find other partners. In becoming the biggest opposition party, the SPD s first task may be keeping a lid on the anti-immigrant Alternative for Germany (AfD), which became the first far right group to win seats in the Bundestag since the 1950s. Thomas Oppermann, head of the SPD in parliament, told broadcaster Phoenix the center-left party would not shy away from legal options to block any racist statements by the AfD. The AfD opposes immigration but denies it is racist. The SPD had hoped for a resurgence under Schulz, a 61-year-old bookseller untainted by the coalition, having served in Brussels as head of the European Parliament rather than in the cabinet alongside Merkel. Schulz s nomination had briefly lifted the party to ratings of around 30 percent, sparking hopes it could win enough seats to form a leftwing coalition. But those gains evaporated steadily in ensuing months as the mild-mannered Schulz failed to drum up voter enthusiasm. Immigration has become a particularly polarizing issue in the two years since Merkel left Germany s borders open to around 1 million migrants mainly fleeing war in the Middle East. The SPD backed Merkel s stance of welcoming refugees. Schulz told supporters at the party s headquarters he would stay on to lead the party in its new role in opposition. He called the election result  a bitter loss,  but said the SPD s drive for social justice, equality and workers  rights was more important than ever given the AfD s gains. He acknowledged that Germans were divided over the arrival of the migrants, but said the party would stick to its values. The main parties of Europe s traditional left have faced a crisis of confidence in recent years, leaving them cast out of power in all but a handful of countries. Some, such as Britain s Labour under Jeremy Corbyn, have tacked to the left to seek support among workers left behind by years of stagnant wages and government austerity policies. Elsewhere, such as in France and Spain, voters have deserted them for new parties led by centrists, populists or both. Jackson Janes, president of the American Institute for Contemporary German Studies, said the SPD had suffered from dissatisfaction affecting all mainstream parties, and from the particular perils facing the left. The party had  lost track of their demographic core group  among working class voters, he said.  The SPD s whole infrastructure was built around the workers, but they don t have a grasp of how the economy has changed for people.  Schulz said party officials would meet on Monday to start remaking the party, but said he was encouraged by the large number of young people who joined the party this year.   Compared with other Social Democratic parties in Europe, we are still firmly grounded in the middle of German democracy,  he said.  20 to 21 percent of the voters is not insignificant.  The most pressing challenge for the SPD is an election on Oct. 15 in the state of Lower Saxony, it lost a one-seat majority with its coalition partners the Greens, and is now trailing the conservatives in the polls. The SPD already ceded power to conservatives twice this year in the states of North Rhine-Westphalia and Schleswig-Holstein. 