A man and a woman were killed on the spot and the injured persons, including 10 students, were taken to a nearby hospital, official media reported.
Seven other injured were adults who were accompanying students to school or passersby, according to the information department of GuilinCity.
Footage on the state television CCTV showed many damaged vehicles lying in front of the school.
The explosion struck about 7.10 am as the students were arriving at the BalijiePrimary School in Lingwu County of Guilin, a resort city in Guangxi.
Witnesses told Xinhua news agency that a man riding a three-wheeled motorcycle passed the entrance to the school when the blast took place.
An eyewitness saw a body lying at the site, which was cordoned off by local police.
"First, the motorcycle caught fire and then exploded with a tremendous noise that could be heard from far, far away," a witness told Xinhua.
A dozen motorcycles were scattered around the blast site and the window panes of cars and stores by the school were damaged.
Police are investigating the cause of blast.
Safety inspections will be conducted across the city of Guilin, in a search for illegal explosives, said a city government statement.
Guilin, a popular tourist city in Guangxi, is famous for its karst scenery.
Another global economic slowdown nears: Investment guru
It's not markets, other financial sectors need ATTENTION
As China's trade outlook worsens, Li unleashes Liconomics
China lowers 2012 GDP to 7.7%
Buckingham Palace breached, 2 held