Authorities charged a 20-year-old man from the St. Louis area with shooting two officers during a protest last week in Ferguson, and they said the alleged gunman had attended the protest earlier in the night.

Jeffrey Williams was arrested late Saturday without a struggle and charged with two counts of first-degree assault. The top prosecutor in St. Louis County, Robert McCulloch, said police relied on tips from the public to identify Williams. He said Williams had admitted firing the shots that struck the officers as they stood guard outside Ferguson police headquarters.

McCulloch said that Williams, who is African American, “is a demonstrator” and that he had also attended other protests in Ferguson — although he did not say how many. “He’s been out there on other occasions, part of the demonstrations,” McCulloch said at a news conference.

That assertion, if proved true, could have a significant impact on Ferguson and its demonstrators — whose leaders have stressed a commitment to non­violent methods.

A handout picture released by the St. Louis County Police Department shows Jeffrey Williams. (St. Louis County Police Department / Handout/Via EPA)

On Sunday, several protest leaders said Williams had not been a familiar face at demonstrations. Several said they had never seen him at all.

“He’s certainly not a regular,” said Tony Rice, who has been the primary organizer of the ongoing protests outside of the Ferguson police building since August. “I’ve never seen that guy before.”

McCulloch, the prosecutor, said that Williams had also told investigators that, when he fired the gun, he was not aiming at the officers in the distance.

“He may have had a dispute with some other individuals, or felt some dispute. We’re not sure we completely buy that part of it,” McCulloch said. “It’s possible he was firing at some other people, and the officers, of course, were in the back. However, it’s still an assault in the first degree.”

One active protest leader, Derrick Robinson, said in an interview Sunday that Williams had told him that he was being robbed at the time of the shooting — and that he shot into the air in response.

“He was in great remorse and said he wishes he could replay it and do it differently,” said Robinson, who visited Williams in jail Sunday.

Robinson, a minister at Kingdom Dominion International Church in Belleville, Ill., said he had seen Williams only once before, at a church event, but visited Williams on Sunday after his name was announced by police. He said Williams had walked past the protest Wednesday evening but had not been an active demonstrator previously.

He also said the 20-year-old had bruises that Williams told the minister came at the hands of officers Saturday night. A spokesman for St. Louis County police said that was untrue.

The protests in Ferguson began last summer, when a white Ferguson police officer shot and killed Michael Brown, an unarmed black 18-year-old. Later, a grand jury declined to indict the officer, Darren Wilson.

Brown’s death was a catalyst for huge demonstrations against what was seen as excessive use of police force and tactics that unfairly targeted African American residents. Police responded with trained rifles and military gear, a reaction that galvanized the country and — to many activists — proved the point.

For many local activists, the key to keeping their moral authority was to channel anger at the police into forceful, but peaceful, demonstrations.

But, at times, those demonstrations have also drawn a fringe of others whose only purpose is confrontation: to lash back, either verbally or physically, at the officers they found in Ferguson. That group was in evidence Wednesday in the hours before the shooting — police reported hearing unusually vulgar, angry taunts from a minority of the demonstrators.

On Sunday, the question was: Who was Williams, and which group did he fall into?

He was not a familiar face among the regular demonstrations outside Ferguson police headquarters. Those events are usually attended by the same 20 to 50 people, and Williams was not one of them.

When the gunfire began, early Thursday, the night’s demonstration had begun to peter out. If the gunman had been at the protest — as police said — he had left at that point and traveled a distance away, on a street that runs uphill from the police building.

Police said that there, from the dark, Williams fired a .40-caliber handgun. The bullets — whether aimed that way or not — traveled more than 100 yards and struck two officers standing in a line outside the station.

One hit an officer from the force in nearby Webster Groves, Mo., spattering blood on his riot helmet’s plexiglass face shield, which apparently was raised at the time. That officer was left with a bullet lodged behind his ear. Another bullet hit a St. Louis County police officer in the shoulder. The bullet exited through his back.

Both officers have been released from the hospital. Police said they were told there was a break in the case Saturday night as detectives closed in on Williams.

McCulloch said that, while ­investigating Williams, police found a handgun that matched the shell casings left at the scene. He was also charged with firing a weapon from a vehicle — McCulloch said at least some of the shots were fired from inside a car.

At the time of the shooting, McCulloch said, Williams already had a warrant out for his arrest. He was on probation for receiving stolen property and had not checked in with his probation officer in seven months.

Williams was in jail Sunday on $300,000 bond. Attempts to contact his family members were not successful.

In a statement after the arrest, Attorney General Eric H. Holder Jr. said that federal ballistics tests had helped link Williams to the crime. “This arrest sends a clear message that acts of violence against our law enforcement personnel will never be tolerated,” Holder said in a statement.

In recent weeks, small measures of change had begun to appear in Ferguson. A scathing Justice Department report found that Ferguson police viewed law enforcement largely as a means to raise city revenue and that they disproportionately targeted African Americans.

Since then, Ferguson’s city manager, top municipal court judge and police chief have all said they will step down.

In the days between the shooting and Williams’s arrest, the unsolved crime left each side of Ferguson’s divide more mistrustful of the other.

Among police, union officials had declared that the shootings were “what the protesters want,” and St. Louis County Police Chief Jon Belmar said that the shooter had been “embedded” in the crowd of demonstrators — a claim he would walk back the following day.

And among demonstrators, some had called the shootings “suspicious,” voicing concerns that the shots were fired by somebody seeking to taint their cause with violence.

Holder excoriated the shooter on the day after the officers were wounded, saying that the shots had been fired by “a damn punk.”

Fahrenthold reported from Washington. Sandhya Somashekhar, Sari Horwitz, Kimberly Kindy and Robert Samuels in Washington contributed to this report.