The man who allegedly threw a bomb inside a California courthouse this week, injuring five people, said he was upset about his firearms being taken away, authorities said. 

Nathaniel James McGuire, 20, of Santa Maria, is charged with maliciously damaging a building by means of an explosive, the Justice Department said Friday. 

He was expected to appear in a Los Angeles federal court Friday.  

VIDEO CAPTURES LOS ANGELES HIT-AND-RUN THAT 'SEVERELY INJURED' A 63-YEAR-OLD WOMAN

A mugshot of Nathaniel McGuire

Nathaniel McGuire is federally charged for allegedly throwing an explosive device in a Santa Barbara County, Calif., courthouse on Wednesday. (Santa Barbara County Sheriff’s Office)

"This defendant will now face justice in federal court for his alleged attack that injured at least five people and struck fear across a county courthouse and an entire community," said U.S. Attorney General Merrick Garland.

McGuire entered the lobby of a Santa Maria courthouse Wednesday, and threw a bag with a bomb, which exploded, federal prosecutors said. After the blast, he fled on foot. 

Five people were injured. 

McGuire was arrested a short time later while trying to get into a Ford Mustang parked outside the building, authorities said. He allegedly yelled that the "government had taken his guns and that everyone needed to fight, rise up, and rebel," the Justice Department said. 

Police say McGuire's motive stemmed from a previous arrest for having an unregistered firearm. He was due in court the morning of the incident.

ATLANTA BUS HIJACKING SUSPECT HAD 19 PRIOR ARRESTS, MENTAL ILLNESSES, FAMILY SAYS

Inside McGuire's car, a Santa Barbara sheriff's deputy allegedly spotted ammunition, a flare gun, and a box of fireworks. Inside, authorities found a shotgun, a rifle, more ammunition, a suspected bomb, and 10 Molotov cocktails, prosecutors said.

Law enforcement later rendered the bomb safe.

Nathaniel McGuire

anta Barbara police arrested Nathaniel McGuire on Wednesday (Google Maps, Santa Barbara Police)

At McGuire’s home, authorities allegedly found an empty can with nails glued to the outside, a duffel bag containing matches, black powder, used and unused fireworks, and papers that appeared to be recipes for explosive material.

None of the five people hit by the explosion faced life-threatening injuries, police say. Four were transported directly to the hospital from the scene, and the fifth traveled to the hospital on their own.

CLICK HERE TO GET THE FOX NEWS APP 

The victims were treated for injuries including burns, and they have now all been released from the hospital.

McGuire faces up to 40 years in prison

Fox News Digital's Anders Hagstrom contributed to this report.