Siale Angilau, 25, died in hospital after being shot several times by a US marshal in front of the jury at the new federal courthouse.
The FBI said Siale Angilau had rushed towards the witness with a pen in an “aggressive, threatening manner”.
Siale Angilau was the last of 17 accused gang members tried as part of a 2010 case.
The case included 29 counts, including assault, conspiracy, robbery and weapons offences.
Perry Cardwell, who was in the courtroom with his adult daughter, told the Associated Press news agency at least six shots were fired.
The witness on the stand at the time was not identified and was not injured.
He appeared to be in his mid-20s and was testifying about gang initiation, Perry Cardwell said.
US District Judge Tena Campbell declared a mistrial, writing in her order that members of the jury were visibly shaken and upset.
Siale Angilau’s lawyer declined to answer questions as he left the court on Monday. The accused had been transferred to federal custody last week after serving time in prison in Utah on other charges.
The new federal courthouse in Salt Lake City opened just a week ago. It was designed with several security features, including bulletproof glass in some areas and separate routes in and out for judges, prisoners and the public.
The building was closed for a while after the shooting but later reopened.
QXMG6DWSVvMImage source: Wikimedia Commons President-elect Donald Trump celebrated his election victory at the Ultimate Fighting…
Millions of voters across the US chose to return Donald Trump to the White House…
Donald Trump declares victory in the US election as he addresses jubilant supporters in Florida.…
Stocks around the world are rising as Donald Trump appears to be on the cusp…
Donald Trump has won Pennsylvania, North Carolina and Georgia and taken a lead over Kamala…
Quincy Jones, the celebrated musician and producer who worked with Michael Jackson, Frank Sinatra, Ray…