Demonstrators throw rocks at Baltimore police during clashes in Baltimore, Maryland April 27, 2015. Several Baltimore police officers were injured on Monday in violent clashes with young people after the funeral of Freddie Gray, a black man who died in police custody, and local law enforcement warned of a threat by gangs. REUTERS/Shannon Stapleton

By Ian Simpson

BALTIMORE (Reuters) - Rioters hurled bricks, looted businesses and set fires in Baltimore on Monday in violence that injured at least seven police officers following the funeral of a 25-year-old black man who died after he was injured in police custody.

The disturbances broke out just a few blocks from the funeral of Freddie Gray and then spread through parts of Baltimore in the most violent U.S. demonstrations since looting in Ferguson, Missouri, last year.

Maryland Governor Larry Hogan declared a state of emergency and activated the National Guard as firefighters tried to extinguish fires set by looters and rioters with baseball bats.

Gray's death on April 19 reignited a public outcry over police treatment of African Americans that flared last year after the killings of unarmed black men in Ferguson, New York City and elsewhere.

After more than an hour of mayhem, hundreds of police moved into glass-strewn streets where the worst of the violence had taken place and used pepper spray on rioters who had sacked check-cashing and liquor stores.

Police and news helicopters buzzed overhead and older community leaders tried to calm down mostly young rioters and prevent clashes with the police. Rioters cut a fire department hose while firefighters fought a fire at a CVS pharmacy looted earlier, the Baltimore Police said.

An Orioles baseball game was canceled and schools, businesses and train stations shut down in the city of 662,000 people 40 miles (64 km) from the nation's capital.

"All this had to happen, people getting tired of the police killing the young black guys for no reason. ... It is a sad day but it had to happen," said Tony Luster, 40, who is on disability and was out on the street watching the police line.

A string of deadly confrontations between mostly white police and black men, and the violence it has prompted, will be among the challenges facing U.S. Attorney General Loretta Lynch, who was sworn in on Monday.

Following her swearing in, Lynch signaled that improving relations between police and the communities they protect will be high on her agenda.

"We can restore trust and faith both in our laws and in those of us who enforce them," she said.

At the White House, while scenes of the riots were broadcast at 5:00 p.m., Lynch briefed Obama. Print and broadcast reporters, kept out of the White House meeting, protested their exclusion.

BALTIMORE A TROUBLED CITY

Wary of violent clashes between black youths and police, pastors and community leaders moved into the area to try to calm tensions. Gray's family had pleaded for peaceful demonstrations.

Looters were nonchalant and showed their faces.

"We went in there and tore it up," said Tyrone Jackson, 16, wearing a hoodie and a thin mustache. He said he was one of the looters inside the CVS.

Just down the street from the smoldering CVS, business owner Daisy Bush, 61, said: "The sad part about it is that a lot of people from the community were up there in the CVS, stealing stuff out of it. It's a disgrace."

Baltimore Police Captain Eric Kowalczyk said at a briefing that one of the injured police officers was unresponsive and several had broken bones.

The largely black city has long struggled with high crime and gangs, a reputation that has made it the setting for gritty television police dramas such as "The Wire." Last year officials adopted one of the strictest youth curfews in the United States in an effort to tackle its crime problems.

At Gray's funeral, speaker after speaker before the crowd packing the 2,500-seat New Shiloh Baptist Church said the world was watching to see if justice would be done for Gray.

Before the service, Gray's body, clad in a white shirt, black tie and dark pants, lay in an open white coffin in front of the altar as mourners passed by. The coffin was closed during the service.

Gray was arrested on April 12 when he fled from police in a high-crime area. He was carrying a switchblade knife, and he was put inside a transport van to be taken to a police station.

At some point, Gray suffered the spinal injury that led to his death a week later. City Police Commissioner Anthony Batts said on Friday that officers failed to belt him into his seat securely and to give him timely medical attention.

Police have said they would conclude their investigation by Friday and forward the results to state prosecutors. Six officers have been suspended, and the U.S. Justice Department is investigating the incident for possible civil rights violations.

(Additional reporting by Scott Malone in Boston, Dan Whitcomb in Los Angeles and Richard Cowan in Washington; Writing by Fiona Ortiz; Editing by Lisa Von Ahn and Lisa Shumaker)