Video of the shocking moment when a white police officer shot Laquan McDonald, a black teenager, 16 times was played to a Chicago jury on Monday at the start of a murder trial.

Jurors saw the police dashcam footage that captured the final seconds of McDonald’s life as Jason Van Dyke, a Chicago police officer, began shooting within six seconds of stepping out of his squad car.

The special prosecutor Joseph McMahon opened the prosecution’s case by telling the jury that “under very special circumstances” a police officer can legally shoot a person.

“A police officer has the legal right to use force and even deadly force but only when it is necessary. What was necessary that night [of] October 20 2014 was the arrest of Laquan McDonald; but it was not necessary to kill Laquan to do so.”

He told the jury they were in court today and Van Dyke was charged with first-degree murder because “not a single shot was necessary or justified”.

McMahon counted off the shots, repeatedly hitting the table in front of him with a finger for emphasis. He said: “In total, this defendant decides to shoot Laquan McDonald not once, not twice, but three, four, five, six, seven eight. He’s only half done. Nine, 10, 11, 12, 13, 14 15, 16 times in total – 16 gunshots into the defenceless body of Laquan McDonald.”

McMahon described police answering a 911 call after McDonald was reportedly seen attempting to break into a truck.

He described how the first police officers on the scene kept a distance from McDonald after spotting him walking. An autopsy would later show that McDonald, who was carrying a 3in bladed knife, had the drug PCP in his system.

McMahon said: “This defendant gets out of his vehicle. From the moment he gets out of his vehicle, six seconds later he pulls the trigger …1.6 seconds after the defendant starts to shoot Laquan McDonald, Laquan McDonald is knocked to the ground, never to get up again.

“For the next 12.5 seconds, the defendant continues to pull the trigger of the gun over and over until he empties the entire clip.”

Protests outside court in Chicago. Photograph: Joshua Lott/AFP/Getty Images

Van Dyke’s partner got out of the car and kicked away the knife. The prosecutor said: “What is the defendant doing? He attempts to reload with 16 more, until his partner stops him and says, ‘We got this’.”

Van Dyke faces two counts of first-degree murder, one charge of official misconduct and 16 counts of aggravated battery, one for each shot fired.

Defence lawyer Daniel Herbert began his opening statement by describing Van Dyke making breakfast for his children, “kissing his beautiful wife” and reporting for his “tour of duty”.

Herbert said: “Jason Van Dyke is not a murderer, had no intention of going out to kill Laquan McDonald. Jason Van Dyke never knew Laquan McDonald. The evidence is going to show that he was a scared police officer, fearful for his life and others and he acted within his training.”

The prosecution argued that McDonald was not on trial and that the officer who shot him had no knowledge of the drugs in his system, nor his troubled childhood and family background. But the defence told the jury that before he died, McDonald had been on “a wild rampage through the city for 24 hours” including attempting to attack someone with a knife.

“The government wants you to look at just the video, the final chapter, without reading the rest of the book, the final two minutes of a two-hour movie, without showing you the context,” Herbert said.

He told the jury: “If the decision to shoot was lawful, there is no crime.”

He said Van Dyke had reason to believe McDonald was going to hurt someone and that he was in fear when he made the decision to shoot.

Herbert said: “What happened to Laquan McDonald is a tragedy. It’s a tragedy, it’s not a murder and that’s what the evidence is going to show.”

McMahon, for the prosecution, emphasised the racial element of the case by saying Van Dyke “saw a black boy walking down the street towards a chain-link fence and having the audacity to ignore the police.”

Herbert, in his opening remarks, said: “The government wants you to think this is a racial issue, because that’s more inflammatory. Race has absolutely nothing to do with this.”

Police officer Joseph McElligott, who had been first on the scene and followed McDonald on foot, testified that he had his gun drawn but never threatened to shoot. He said: “He seemed really out of it. He just kept walking away from us.”

Van Dyke entered the Leighton criminal court building at about 7.45am before any protesters arrived. He was surrounded by a security detail and one report said he was wearing a bulletproof vest under his suit.

Seven protesters arrived about 8.30am, marching as they chanted: “From the slave catchers and the KKK to the killer cops of today, convict Van Dyke and throw him in jail. The whole damn system is guilty as hell.”

Van Dyke is the first Chicago police officer to face trial for killing someone on duty in 50 years. The graphic video – released the day Van Dyke was charged – led to months of protests and political upheaval.