The governor declared a state of emergency and called in the National Guard to restore order.
Seven officers were hurt, some with broken bones, and one was unresponsive, said Capt. Eric Kowalczyk. Officers wearing helmets and wielding shields occasionally used pepper spray to keep the rioters back. For the most part, though, they relied on line formations to keep protesters at bay.
Monday's riot was the latest flare-up over the mysterious death of Freddie Gray, whose fatal encounter with officers came amid the national debate over police use of force, especially when black suspects are involved. Gray was African-American.
Emergency officials were constantly thwarted as they tried to restore calm. Firefighters trying to put out a blaze at a CVS store were hindered by someone who sliced holes in a hose connected to a fire hydrant, spraying water all over the street and nearby buildings.
The smell of burned rubber wafted in the air in one neighborhood where youths were looting a liquor store. Police stood still nearby as people drank looted alcohol. Glass and trash littered the streets, and small fires were scattered about. One person from a church tried to shout something from a megaphone as two cars burned.
Gray's family was shocked by the violence and was lying low; instead, they hoped to organize a peace march later in the week, said family attorney Billy Murphy. He said they did not know the riot was going to happen and urged calm.
"They don't want this movement nationally to be marred by violence," he said. "It makes no sense."
Police urged parents to locate their children and bring them home. Many of those on the streets appeared to be African-American youths, wearing backpacks and khaki pants that are a part of many public school uniforms.
The riot broke out just as high school let out, and at a key city bus depot for student commuters around Mondawmin Mall, a shopping area northwest of downtown Baltimore. It shifted about a mile away later to the heart of an older shopping district and near where Gray first encountered police. Both commercial areas are in African-American neighborhoods.
Downtown Baltimore, the Inner Harbor tourist attractions and the city's baseball and football stadiums are nearly 4 miles away. While the violence had not yet reached City Hall and the Camden Yards area, the Orioles canceled Monday's game for safety precautions.
Many who had never met Gray gathered earlier in the day in a Baltimore church to bid him farewell and press for more accountability among law enforcement.
The 2,500-capacity New Shiloh Baptist church was filled with mourners. But even the funeral could not ease mounting tensions.
Police said in a news release sent while the funeral was underway that the department had received a "credible threat" that three notoriously violent gangs are now working together to "take out" law enforcement officers.
A small group of mourners started lining up about two hours ahead of Monday's funeral. Placed atop Gray's body was a white pillow with a screened picture of him. A projector aimed at two screens on the walls showed the words "Black Lives Matter & All Lives Matter."
The service lasted nearly two hours, with dignitaries in attendance including former Maryland representative and NAACP leader Kweisi Mfume and current Maryland Rep. John Sarbanes.
Erica Garner, 24, the daughter of Eric Garner, attended Gray's funeral. She said she came after seeing video of Gray's arrest, which she said reminded her of her father's shouts that he could not breathe when he was being arrested on a New York City street. Garner died during the confrontation.
"It's like there is no accountability, no justice," she said. "It's like we're back in the `50s, back in the Martin Luther King days. When is our day to be free going to come?"
With the Rev. Jesse Jackson sitting behind him, the Rev. Jamal Bryant gave a rousing and spirited eulogy for Freddie Gray, a message that received a standing ovation from the crowded church.
Bryant said Gray's death would spur further protests, and he urged those in the audience to join.
"Freddie's death is not in vain," Bryant said. "After this day, we're going to keep on marching. After this day, we're going to keep demanding justice."
Gray was arrested after making eye contact with officers and then running away, police said. He was held down, handcuffed and loaded into a van without a seat belt. Leg cuffs were put on him when he became irate inside.
He asked for medical help several times even before being put in the van, but paramedics were not called until after a 30-minute ride. Police have acknowledged he should have received medical attention on the spot where he was arrested, but they have not said how his spine was injured.