The attack targeted the Celebi Eser middle school in Diyarbakir's Baglar district on the last day of school when students receive report cards before a winter break, the regional education official Adnan Hurata told the state-run Anadolu Agency.
Turkey's security forces are fighting militants linked to the Kurdistan Workers' Party, or PKK, in Diyarbakir's historic Sur district. Authorities are enforcing a 24-hour curfew in Sur as the security forces press ahead with large-scale operations to rout out the militants.
All five students were hospitalised but none of them is in serious condition, Hurata said.
The Kurdish rebel group, which wants autonomy for Kurds in southeastern Turkey, has targeted schools in the past because it oppose the Turkish education system, which it says aims to assimilate Kurds.
Fighting between the PKK and the security forces reignited in July, shattering a two-year-old peace process that aiming to end the three-decade conflict that has killed tens of thousands of people.