Eighteen people suffered serious injuries, according to the local government website.
Twelve bodies have been identified. They include two local residents and at least six tourists, who were visiting Jiuzhaigou national park, the epicentre of the quake some 285 kilometres north of Chengdu.
The 720-square-kilometre mountainous park, a UNESCO world heritage site known for its karst scenery and waterfalls, was closed when the quake struck at 9:19 pm on Tuesday (1319 GMT), it said.
Tremors from the earthquake were felt in Beijing, more than 1,200 kilometres away.
The U.S. Geological Survey reported a magnitude-6.5 quake, while state media cited a magnitude-7.0 quake