Numerous demonstrators wore red headbands eulogising the slain security force members as “martyrs”.
The Turkish military says it has killed 5 Kurdish rebels in airstrikes on the southeastern province of Hakkari.
Writing in the leading independent Hurriyet daily this week, columnist Paul Iddon warned Erdogan against any attempt to undermine the HDP, the first pro-Kurdish party to win seats in parliament.
A combative Mr Erdogan, who had been counting on the AKP winning a large majority in order to amend the constitution to boost his powers, laid into the HDP, without expressly naming it.
Erdogan and the AKP he founded have gone on the offensive, accusing the HDP of ties to the banned Kurdistan Workers Party (PKK), designated a terrorist group by Washington and Ankara.
Turkish warplanes have bombed Kurdish militant targets in southeastern Turkey, destroying ammunition and fuel depots and killing five militants, the army said on Monday.
Around 150 soldiers and police have been killed since the return to open conflict, compared with over a thousand rebels, according to pro-government media.
More than 40,000 people have been killed during more than three decades of the PKK’s insurgency.
Between 2013 and 2015, at least 410 children fled from the PKK and surrendered to Turkish security forces. When he heard the demonstrators chanting “We don’t want the PKK in the parliament” he said: “Then you will work hard for the November 1 [election] and leave them under the [election] threshold”.
UNICEF said that such abuse was illegal and called on the PKK to halt the practice.
People rally to denounce the PKK group, which has been carrying out an armed campaign against the Turkish state.
According to Turkish authorities, over 110 police officers, servicemen and civilians became victims of the Kurdish militants in the past two months.
Germany is home to a three-million-strong ethnic Turkish community, with many having immigrated in the 1960s and 1970s for employment.