By Curtis Skinner

SAN FRANCISCO (Reuters) - Thousands took to the streets of U.S. cities on Friday to denounce the fatal shooting by police of two black men this week, marching the day after a gunman killed five police officers watching over a similar demonstration in Dallas.

Protesters clogged roadways in New York City, Atlanta and Philadelphia, and events in San Francisco and Phoenix also drew large crowds.

Six people were injured and three were arrested in Phoenix. where police in riot gear used pepper spray on protesters, some of whom threw rocks at officers, the Phoenix Police Department said in a statement.

Videos posted online showed protesters also gathering in Baton Rouge, Louisiana, where 37-year-old Alton Sterling was fatally shot by police early on Tuesday.

The largest demonstration appeared to be in Atlanta, where thousands marched, chanting and waving signs demanding justice, video posted to social media showed. Footage from broadcasters showed a large crowd facing off with dozens of police vehicles blocking a local interstate highway.

Atlanta Mayor Kasim Reed tweeted that the rally was largely peaceful, though about 10 people had been arrested.

Friday was the second day of demonstrations against use of force by police following the fatal shootings of Sterling and of 32-year-old Philando Castile near St. Paul, Minnesota.

The shootings stoked racial tension that has flared repeatedly across the country following the 2014 killing of Michael Brown, an unarmed black teen, by a white police officer in Ferguson, Missouri.

Castile was killed by police during a traffic stop on Wednesday, and his girlfriend posted footage of the confrontation on the Internet minutes later.

Sterling was killed on Tuesday during an altercation with two white police officers outside a convenience store. A graphic video of that incident caused an outcry on social media.

"No justice, no peace, no racist police," demonstrators shouted late on Friday in Baton Rouge, where state and local police in riot gear tried to keep them from blocking a busy roadway.

Thursday's demonstrations following the killings of Sterling and Castile were largely peaceful until gunfire erupted at a Dallas rally that was winding down.

Authorities said 25-year-old Micah Johnson, a black U.S. military veteran of the Afghan war who said he wanted to "kill white people," launched a sniper attack that killed five police officers and wounded nine other people.

Police killed the gunman with a bomb-carrying robot after cornering him in a parking garage, ending an hours-long standoff.

(Additional reporting by Bryn Stole in Baton Rouge, Louisiana and Brendan O'Brien in Milwaukee; Editing by Colleen Jenkins and Clarence Fernandez; editing by John Stonestreet)