Dramatic video released yesterday shows a US marshal firing four times at close range at a defendant inside a Utah federal courthouse after he rushed the witness stand, jumped and swung with a pen at a shackled witness who barely backed out of the way.

The 24-second footage from the 2014 gang-related racketeering trial was released after a media coalition including The Associated Press argued it was a public record in an important police use-of-force case.

The video shows defendant Siale Angilau, a 25-year-old member of the Tongan Crip gang, calmly rising from his seat beside his attorney during the witness testimony and grabbing his lawyer's pen.

As someone yells, "whoa, whoa, whoa" but before any officers could react, Angilau sprinted toward the witness and leaped with his right arm cocked overhead with the pen in hand.

The man jumped back to avoid being hit as Angilau fell over the front of the witness stand.

That's when the unidentified US marshal shot Angilau four times.

A woman cried out in horror while other law enforcement in suits ran toward the witness stand. Angilau's defence attorney jumped under a desk while prosecutors stood in shock.

A bailiff swiftly moved to block the entrance to the front of the court and pointed at people in the gallery and told them to stay still with his right hand on his holstered weapon.

"Get on the ground," someone yelled in the direction of Angilau.

"Drop the pen. Drop the pen out of your hand," yelled an officer standing over Angilau.

As US District Judge Tena Campbell was escorted out of the courtroom, someone called 911.

The unidentified US marshal was cleared of any wrongdoing shortly after the shooting.

The Department of Justice wanted the video kept under seal over concerns it could lead to retaliatory gang violence. Faces of the judge, attorneys and jurors are blurred out.

The agency didn't immediately respond to a phone call and email requesting comment.