Siale Angilau, 25, died at a hospital after he was shot in the chest as he rushed the witness with a pen in an "aggressive, threatening manner," the FBI said in a news release.
Angilau was shot several times in front of a jury that had been selected on Friday.
Angilau was one of 17 people named in a 29-count racketeering indictment filed in 2010 accusing gang members of assault, conspiracy, robbery and weapons offenses.
Under standard procedures, Angilau was not restrained in the courtroom, the FBI said.
Perry Caldwell, who was in the courtroom with his adult daughter, said Angilau was shot several times as he lunged toward the witness stand.
At least six shots were fired, he said.
The witness, who was not injured, appeared to be in his mid-20s and was testifying about gang initiation, Caldwell said. The person was not identified.
Caldwell and his daughter were in court to support his mother, Sandra Keyser, who was punched in the face during a holdup in 2002 and was scheduled to testify.
"It was kind of traumatizing," Sara Jacobson, Caldwell's daughter, said of the shooting.
Prosecutors said Angilau robbed convenience stores and assaulted clerks in Salt Lake City on five occasions from 2002 to 2007. A clerk was shot in the final robbery, according to the indictment.
Angilau was accused of assault on a federal officer with a weapon and discharging a firearm during a crime of violence on Aug. 11, 2007.
Angilau was the last defendant in the case to stand trial, U.S. attorney's office spokeswoman Melodie Rydalch said.
A mistrial was declared after the shooting. In her order, U.S. District Judge Tena Campbell said members of the jury were visibly shaken and upset.
Angilau's attorney, Michael Langford, declined to take questions as he left the courthouse.
Angilau was in Utah state prison from September 2007 until he was handed over to U.S. marshals on Friday, said Utah Department of Corrections spokeswoman Brooke Adams.
He was arrested in August 2007 for a probation violation and pleaded guilty a year later to obstruction of justice and failure to respond to a command of a police officer, court records show.
His trial in the robbery case was among the first at the new $185 million federal courthouse opened just one week ago in downtown Salt Lake City next door to a century-old federal courthouse. The towering building is designed to withstand blasts and also contains bulletproof glass in some areas.
The security measures include separate routes in and out for judges, prisoners and the public. In the old courthouse, they all used the same hallways.
The courthouse was temporarily closed after the shooting and later reopened.