Erdoğan had left by helicopter from the city of Kastamonu by the time of the attack, which targeted a police vehicle providing an escort for an AK Party campaign bus.
Campaigning has begun for a parliamentary election on June 12 that is expected to result in Erdoğan winning a third consecutive term.
Television pictures showed Erdoğan subsequently arriving at another election rally in the northern province of Amasya, where he was greeted by thousands of AK supporters waving party flags.
He blamed separatist militants for the attack, casting suspicion on the Kurdistan Workers Party (PKK) and its affiliates.
"Those dark minds, these terrorists, these separatists are only able to do this, those who understand there is nothing they can do through the ballot box," Erdoğan said in Amasya.
"Our people will never allow these terrorists, these bandits to divide them," he said, addressing the rally in full view but flanked by two bodyguards.
State broadcaster TRT said initial information pointed to the PKK as perpetrators. It did not provide any details.
The attack came after thousands of Kurds gathered in the main southeastern city of Diyarbakir Wednesday for a funeral of PKK terrorists killed in a clash with security forces in the province of Tunceli last week.
The PKK ended a six-month ceasefire in February and there have been fears of rising violence ahead of the election.
Media reports a month ago said the interior ministry and police had warned against potential attacks by the PKK in the Black Sea region, and in Kastamonu in particular.
The attack happened on a country road winding through thickly forested hillsides south of Kastamonu.
According to sources, a grenade was thrown at the police vehicle and gunmen opened fire as it burst into flames. One report quoted a senior local official as saying no explosive was thrown.
Television images showed fire services arriving at the scene and smoke rising from the police car and an ambulance parked nearby, while security forces combed the hillsides.
PKK militants attacked a police vehicle in the Black Sea province of Sinop last month, injuring three police officers.
Kastamonu province, on the Black Sea, had not previously been known as a scene of guerrilla violence.
However, Kurdish, leftist and Islamist militants have often carried out gun and bomb attacks across Turkey in the past.
More than 40,000 people have been killed in a separatist conflict in southeastern Turkey since the PKK took up arms against the state in 1984.
The AK Party took power in 2002, and while it has overseen a period of unprecedented prosperity, critics fear it harbors a secret agenda to roll back the republic's secular constitution.
Erdoğan denies any such intention, although he does plan to introduce a new constitution if elected in order to make a clean break with a past era of military rule.
Prosecutors say the AK government has been targeted by a series of coup plots involving violent attacks by suspected militant secularists in recent years. Hundreds of people are on trial on conspiracy charges.