BALTIMORE — Rioters plunged part of Baltimore into chaos Monday, torching a pharmacy, setting police cars ablaze and throwing bricks at officers hours after thousands mourned the man who died from a severe spinal injury he suffered in police custody.

The governor declared a state of emergency and called in the National Guard to restore order, and Attorney General Loretta Lynch, in her first day on the job, said she would send Justice Department officials to the city in coming days. A weeklong, daily curfew was imposed beginning Tuesday from 10 p.m. to 5 a.m., the mayor said, and Baltimore public schools announced that they would be closed on Tuesday. At least 15 officers were hurt, and some two dozen people were arrested. Two officers remained hospitalized, police said.

“The National Guard represents the last resort in restoring order,” Gov. Larry Hogan told a news conference. “I have not made this decision lightly.”

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. Police have declined to specify the races of the six officers involved in his arrest, all of whom have been suspended with pay while they are under investigation.

Emergency officials were constantly thwarted as they tried to restore calm in the affected parts of the city of more than 620,000 people. 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. Later Monday night, a massive fire erupted in East Baltimore that a spokesman for Mayor Stephanie Rawlings-Blake initially said was connected to the riots. He later texted an AP reporter saying officials are still investigating whether there is a connection.

The Mary Harvin Transformation Center was under construction and no one was believed to be in the building at the time, said the spokesman, Kevin Harris. The center is described online as a community-based organization that supports youth and families.

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 other small fires were scattered about. One person from a church tried to shout something from a megaphone as two cars burned.

“Too many people have spent generations building up this city for it to be destroyed by thugs, who in a very senseless way, are trying to tear down what so many have fought for, tearing down businesses, tearing down and destroying property, things that we know will impact our community for years,” said Rawlings-Blake, a lifelong resident of the city.

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.

Later in the day, people began looting clothing and other items from stores at the mall, which became unprotected as police moved away from the area. About three dozen officers returned, trying to arrest looters but driving many away by firing pellet guns and rubber bullets.

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.

On Monday night, Maryland Congressman Elijah Cummings and about 200 others, mostly men, marched arm-in-arm through a neighborhood littered with broken glass, flattened aluminum cans and other debris, to protest Gray’s death. As they got close to a line of police officers, the marchers went down on their knees. After the ministers got back on their feet, they walked until they were face-to-face with the police officers in a tight formation and wearing riot gear.

In a statement issued Monday, Attorney General Lynch said she would send Justice Department officials to the city in coming days, including Vanita Gupta, the agency’s top civil rights lawyer. The FBI and Justice Department are investigating Gray’s death for potential criminal civil rights violations.

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.

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.

———

Associated Press writers Juliet Linderman and Jeff Horwitz contributed to this report.