FERGUSON, Mo. -- With measured remarks and a conciliatory tone, police, political leaders and civil-rights activists on Thursday sought to tamp down tensions after two police officers were shot in front of the Ferguson Police Department during a protest.

The officers were quickly released from the hospital, but St. Louis County Police Chief Jon Belmar said they could have easily been killed and called the attack "an ambush." Several people were taken in for questioning after a SWAT team converged on a Ferguson home near the shooting site, but they were later released, and no arrests were made.

The shootings marked the first time in more than seven months of tension in Ferguson that officers were shot at a protest, and the bloodshed threatened to inflame the already fraught relationship between police and protesters just as the city seeks reforms in the wake of a withering Justice Department report on racial bias in its law-enforcement practices.

The attack also seemed to create another layer of race-related mistrust after a week in which an unarmed young black man was killed by a white officer in Madison, Wisconsin, and a University of Oklahoma fraternity chapter was thrown off campus after a video surfaced showing members singing a racist chant.

In Washington, President Barack Obama took to Twitter to relay his prayers to the officers and to denounce violence against police. "Path to justice is one all of us must travel together," Obama wrote, signing the tweet with his initials to indicate the president personally composed it.

Attorney General Eric Holder said the gunman was "a damn punk" who was "trying to sow discord in an area that was trying to get its act together, trying to bring together a community that had been fractured for too long."

The shots were fired early Thursday just as a small crowd of protesters began to break up after a late-night demonstration that unfolded hours after the resignation of Ferguson Police Chief Tom Jackson.

The shots were believed to come from a handgun across the street from the police department, which has been a national focal point since the fatal Aug. 9 shooting of Michael Brown, who was black and unarmed, by a white police officer.

The gunman may have fired from up to 120 yards away, a distance longer than a football field. But with a line of roughly 20 officers standing in front of the building, the shooter did not have to be particularly accurate to hit two of them, Belmar said.

"We're lucky by God's grace we didn't lose two officers last night," he said.

A 41-year-old St. Louis County officer was shot in the right shoulder, the bullet exiting through his back. A 32-year-old officer from Webster Groves was wearing a riot helmet with the face shield up. He was shot in the right cheek, just below the eye, and the bullet lodged behind his ear.

On Thursday night, about 50 people gathered at a public plaza in downtown Ferguson near the police station for a vigil. The group sang spirituals, prayed for peace and expressed sympathies for the injured officers.

Later, a larger group marched, chanted and beat drums in the street in front of the police department. Some were demanding the resignation of Ferguson Mayor James Knowles III. About 20 officers were visible outside the station.

Tensions have been high in Ferguson since August and escalated in November after a St. Louis County grand jury declined to prosecute Darren Wilson, the officer who shot Brown. Justice Department investigators concurred with that finding in a report released March 4.

But a separate Justice Department report released that same day found racial profiling in the Ferguson police force, and a municipal court system driven by profit, largely on the backs of black and low-income residents.

In the week after the report, Ferguson's court clerk was fired and the municipal judge, two police officers and the city manager voluntarily stepped aside. Wilson resigned in November.

John Gaskin III, a St. Louis community activist, speculated that the shooting was conducted by outside agitators intent on hijacking attention from peaceful, reform-minded protesters.

Activists "cannot afford these kinds of incidents happening, because that gets us absolutely nowhere."

In a statement, Knowles and the city council said although they respect the right to protest peacefully, "we cannot continue to move forward under threats of violence and destruction to our community. We ask our residents and clergy in this area to partner with us as we make our way through this process."

Belmar said he reached out to civil-rights leaders, asking them to urge peace. He treaded lightly in response to questions about how police will prepare for other potential demonstrations, saying he would seek officers from other departments.

Officers from St. Louis County and the Missouri State Highway Patrol planned to take over protest security in Ferguson on Thursday evening.

Not everyone was conciliatory.

Jeff Roorda, spokesman for the St. Louis police union, said the shooting was evidence that many people are not satisfied with Jackson's resignation.

"What they wanted was to kill police officers, and that's what they tried to do," Roorda said.

He called for nighttime curfews. St. Louis County Executive Steve Stenger said there are no plans to institute a curfew.

In amateur video of the shooting accessed by The Associated Press, two shots ring out and a man is heard screaming out in pain.

Someone at the scene, unseen and unidentified in the video, says: "Acknowledgement nine months ago would have kept that from happening."

Officers saw some alarming trends prior to the shooting, Belmar said.

Fist fights broke out among protesters. Rather than staying in one group in a parking lot across from the police station, demonstrators were spread out over a wide area. Some reportedly threw rocks and bottles. Three people were arrested.

Though the crowd was small compared with some earlier protests, with fewer than 200, Ferguson officers were concerned enough to ask officers from neighbouring towns to assist. By 10 p.m., 69 officers had responded, Belmar said.

Some protesters said there was a different vibe than most nights.

"It was a very rowdy group," said Kristie Johnson, 32, who has been a frequent protester. "They were fighting each other. A lot of people out here tonight we haven't seen before."

Marciay Pitchford, 20, said she was near the street.

"All of sudden gun shots came through and everybody just started running," she said. "It seemed like they were just trying to shoot any police officer. It came from behind our heads."

------

Associated Press writers Alan Scher Zagier in Ferguson, Missouri; Eric Tucker and Josh Lederman in Washington; Greg Moore and Heather Hollingsworth in Kansas City, Missouri; and Summer Ballentine and Marie French in Jefferson City, Missouri, contributed to this report.