INGOLSTADT, Germany (Reuters) - The Social Democrat (SPD) challenger to Chancellor Angela Merkel in Germany's national election in September said on Monday the anti-capitalist militants who protested against the G20 summit in Hamburg at the weekend had acted like terrorists.

About 20,000 police struggled to contain several hundred demonstrators who torched cars, looted shops and hurled Molotov cocktails and stones during the July 7-8 summit. Tens of thousands more people demonstrated peacefully.

SPD leader Martin Schulz said the "marauding gangs" could not claim to have any political legitimacy for their actions, adding: "It had the characteristics of terrorism."

"Such small-minded skirmishes are the business of people who took a whole city hostage for their dimwittedness in an almost terrorist manner," said Schulz, whose party is trailing Merkel's conservatives in the opinion polls.

During the protests in Hamburg 476 officers were injured and police said on Sunday they had arrested 186 people and taken 225 into custody.

Germans have expressed anger about the violence in Hamburg and Merkel has promised compensation to those who had property damaged.