The official Xinhua news agency reports the sharp quake jolted Toksun County of Turpan Prefecture at 9:53 a.m. local time on Wednesday, causing several big rocks to roll onto a mountain road in the neighboring Dabancheng District.
This forced one driver to slam on his brakes, which led to a 17-car pileup.
Officials said that none of the eight people injured were in life-threatening conditions.
The quake also damaged about 50 homes and prompted the suspension of rail service while tracks were inspected.
Hundreds of students in Toksun County were taking a national college entrance exam when the quake struck.
Xinhua reports the students were given an extra 70 to 90 minutes to complete the exam after being evacuated and returned to the classroom.