Erdogan spotted the weeping-and-saluting 6-year-old Amine Tiras while delivering a speech at his ruling party's congress in the city of Kahramanmaras on Saturday, and had her brought on stage.
After trying to comfort the girl by kissing her on both cheeks, Erdogan told the crowd: "She has the Turkish flag in her pocket. If she becomes a martyr, God willing, this flag will be draped on her."
Some people were appalled and took to Twitter to criticize the president.
One user said it was the state's duty to protect children, not to "kill" them.
Another said: "you don't wish death for a child, you never say: 'God willing.'"
His action comes as nationalist sentiment is running high over a Turkish cross-border military offensive against Syrian Kurdish fighters that are affiliated with Kurdish rebels fighting inside Turkey.
In recent weeks, children dressed in commando uniforms or reciting nationalist poems have been making appearances in many events that he attends.
Yasar Okutan, a former government minister, accused Erdogan in a television interview of using them to increase votes in presidential and local elections in 2019 and questioned whether the president would say the same for his own granddaughter.
Want to enjoy 'Zen' reading - with no ads and just the article? Subscribe todaySubscribe now