The gunman behind a double shooting in Copenhagen last year had intended to kill Swedish artist Lars Vilks when he attacked a cultural centre, a man accused of helping him told a court on Thursday.
Instead Omar El-Hussein, 22, killed a Danish film-maker in the attack on February 14, 2015.
Vilks, reviled by Islamists for his sketch of the Prophet Mohammed in 2007, was one of the speakers at an event focused on blasphemy and freedom of expression.
Danish police as well as Vilks himself have previously said they believe he was the target of the attack.
"It wasn't he who was meant to die," 26-year-old Bhostan Hossein told the court, referring to victim Finn Nørgaard.
He and three others are on trial for helping and encouraging the perpetrator.
After the first attack, the four suspects had met with El-Hussein near the housing estate where he grew up, he said.
At that point he told them that the real target had been "he who was inside. Lars Vilks? The Mohammed cartoonist", Hossein said, on the fifth day of the trial.
Two of the suspects -- Hossein and 21-year-old Liban Elmi -- are also accused of helping El-Hussein get rid of an assault rifle used outside the free speech event.
Surveillance footage from a nearby train station showed the two meeting him after the first attack, and Hossein being handed a black bag believed to contain the weapon.
"I could feel that it was a gun. I tried to give it back. He would not take it.... Having seen the news I could figure out what had happened," he said.
Asked why he had not called the police, he said: "I'm a criminal. It's very normal."
The M95 rifle was later found in a ditch near the railway tracks.
Later that night, the Danish-Palestinian fired shots outside Copenhagen's main synagogue, killing Jewish security guard Dan Uzan. El-Hussein died hours later in a shootout with police.
The prosecution believes the suspects' "continuous and close contact" with the killer in the hours between the attacks, as well as support including clothing and ammunition used in the second attack, violate Denmark's terrorism law.
It has set aside 30 days for the trial, with a verdict expected in September.