A 24-year-old man was arrested early Tuesday in connection to a baseball bat attack on a U.S. marshal, as authorities attempted to disperse protesters in Portland last month.

The incident involving Dakotah Ray Horton occurred around 1:20 a.m. July 27 outside the Mark O. Hatfield United States Courthouse, the site of much of the violence in the city over several weeks.

Federal officers were attempting to disperse a crowd armed with bats, hockey sticks and shields when someone tried cutting through a fence with power tools, Deputy U.S. Marshal Christopher Tamayo wrote in a federal affidavit obtained by Fox News.

LONGER PORTLAND ASSAULT VIDEO RELEASED SHOWING MOMENTS LEADING UP TO ATTACK OF TRUCK DRIVER

Dakotah Ray Horton

Dakotah Ray Horton (Mulnomah County Sheriff's Office)

Meanwhile, federal officers were pelted with glass bottles, explosives and other hard objects, the document said.

As several officers attempted to arrest a protester, officials said Horton struck one U.S. marshal kneeling on the ground in the upper back, neck and shoulder area with a wooden baseball bat. The officer suffered bruising to the back and shoulder, Tamayo wrote.

In an effort to identify the assailant, the U.S. Marshals Service on Aug. 2 issued a bulletin in the Portland area with close-up images of his face and clothes.

Images capture a bat-wielding suspect accused of striking a federal officer during a July 27 protest in downtown Portland.

Images capture a bat-wielding suspect accused of striking a federal officer during a July 27 protest in downtown Portland. (U.S. District Court)

Investigators compared live footage and screenshots of the suspect, with others posted on social media.

Just before midnight Monday, Horton was spotted by a deputy U.S. marshal leaving an apartment wearing the same clothes as the suspect the night of the attack. He got into a car that later was stopped by authorities and he was arrested.

Images capture a bat-wielding suspect accused of striking a federal officer during a July 27 protest in downtown Portland.

Images capture a bat-wielding suspect accused of striking a federal officer during a July 27 protest in downtown Portland. (U.S. District Court)

CLICK HERE TO GET THE FOX NEWS APP

Officers found a 9mm handgun he was wearing in a waist holster, according to court documents.

Horton was scheduled to make a court appearance Wednesday. It was not clear if he entered a plea.