They also threw explosives during the attack in the regional capital Urumqi. More than 90 people were injured, the state-run Xinhua news agency said.
The Ministry of Public Security called it a "violent terrorist incident".
Xinjiang, which is home to the Muslim Uighur minority, has seen a spate of attacks in the past year.
Information about incidents in the region, where ethnic tensions between Uighurs and Han Chinese continue, is tightly controlled.
Pictures on Weibo microblogs - China's equivalent of Twitter - appeared to show Thursday's attack taking place at one end of a busy market street lined with vegetable stalls.
One of the two vehicles exploded.
The Chinese government's effort to mount a "people's war" against terror has made little headway in a climate where many Uighurs feel they are victims of discrimination, religious repression and economic marginalisation.
A foreign ministry spokesman said Beijing had the confidence and capability to crack down on terrorists. But that must now be in doubt. The number of attacks is growing. They are no longer confined to the north-west, and targets now include civilians, raising credibility questions for a government which prizes security.
During a visit to Xinjiang last month, President Xi Jinping promised greater integration and warned terrorists would be isolated "like rats scurrying across a street". But attacks like today's serve to escalate mistrust between Uighurs and the majority Han population making it even harder to resolve the underlying problems that feed the violence.
The injured were taken to several hospitals, Xinhua said.
"I saw people lying all over the place, it was a very bad sight, " one taxi driver was quoted as saying by AFP news agency. "How can they do this at a market where elderly people shop?"
Foreign Ministry spokesman Hong Lei said the attack laid bare the "anti-civilisation nature of the violent terrorists and deserves the condemnation of the world community and the Chinese people''.
The World Uyghur Congress said the authorities in the Chinese capital Beijing should not increase the crackdown in Xinjiang.
A spokesman told the BBC the violent incidents were a direct result of Beijing's policies in the region.
A flight from Shanghai to Urumqi on Thursday was diverted and landed at Nanjing for security reasons, Xinhua reported.
Separately, new security measures have been announced for key areas of Beijing.
I didn't go downstairs because I was scared. I was the only one [at home]. I was worried for my safety. I heard the first two blasts, like a thunderstorm, and I thought it was one. Then there were another three to four explosions, and then smoke billowing, and everybody downstairs was running... The ambulances arrived immediately (within 10 minutes), then came a police car. More ambulances, fire trucks and police cars arrived within 30 minutes.
Urumqi attacks: Eyewitness accounts
Xinjiang lies in China's far west, bordering Central Asia.
China says it is pouring money into the region, but some Uighurs say their traditions are being crushed.
In 2009, tensions erupted. Riots in Urumqi left some 200 people dead.
Why is there tension between China and the Uighurs?
Beijing has blamed a series of violent incidents on Uighur separatists. These include an attack in Beijing, where a car ploughed into pedestrians in Tiananmen Square, killing five people, and attacks at railway stations in Urumqi and Kunming.
Earlier this week, Chinese courts jailed 39 people as part of what the authorities called an operation to curb the spread of audio and video materials inciting terrorism.
Those jailed included a 25-year old who had incited hatred in comments made in chat rooms and a father who had preached extremism to his son, the Xinjiang Supreme Court said.
Attackers in China's restive Xinjiang region have crashed two cars into shoppers at a market, killing 31 people, Chinese media reports say.