PORTLAND, Maine — When Sean Dundon heard the scream, at first he thought someone had been in a car accident.

“I heard a sound as if someone was really in pain,” he said.

Then he looked out the window of his second-story State Street office and saw a man standing on the sidewalk in front of a statue of Henry Wadsworth Longfellow, the top half of his body in flames.

“Everybody was helping him, but he had been on fire for half a minute,” Dundon said.

Police say the man, who they have identified only as a 24-year-old Portland resident, apparently doused himself with a flammable material and set himself ablaze in Longfellow Square at the intersection of Congress and State streets.

The Portland Press Herald said that authorities have identified the man as David Parker, 24, and that Parker is in Boston being treated for his burns.

The man was taken to Maine Medical Center with severe burns. Police say next of kin have been notified, but they aren’t releasing his name.

According to a release from the Portland Police Department, rescue crews received a report at 12:17 p.m. of a man on fire in Longfellow Square. Officers arrived and found a male victim suffering from burns.

Police said witnesses reported that the man had walked into the square and intentionally set himself on fire.

Witnesses attempted to smother the flames and a passing motorist stopped and extinguished the flames with a fire extinguisher from his vehicle.

John Wayne, the owner of Japanese restaurant King of the Roll, said two or three of his customers seated in the outdoor patio area jumped to action when they saw the man on fire. One of the men grabbed the welcome mat from the restaurant and attempted to carry it across the street, but it was too heavy.

Dundon said black smoke came off the man as he burned. He said the man appeared to be wearing a suit and had a backpack with him, which he was not wearing. A small red lighter was on the ground, he said.

City spokeswoman Nicole Clegg said the square is a “highly trafficked area in the city,” but she did not know how many people witnessed the event.

“It was 12:15 on a nice afternoon around lunchtime. It was busy down there,” said Lt. Gary Rogers of the Portland Police Department.

Both Clegg and Rogers said it was unlikely that the man set himself on fire in protest.

“We don’t have any indication that this was a protest,” he said.

Chris Hallweaver reported on his Twitter account that the man was completely aflame by the time a shop owner got to him with a fire extinguisher and that he was yelling, “Kill me. Just kill me.”

The Press Herald reported the police as saying the man apparently doused himself with gasoline in his apartment at 675 Congress St. before walking across the street, where he set himself on fire.

Jan Bowling, a State Street resident, said she saw firefighters enter the side entrance of 675 Congress later in the afternoon and walk out carrying a can of gasoline.

Rogers could not confirm the man lived at that address.

The owner of a bookstore across the street, who declined to be identified, said she was impressed by how everyone worked together.

“It speaks very highly of Maine because in some cities, a man could set himself on fire and they could walk past. Here, they helped to put him out.”

She said she saw a large plume erupt when the man lit himself on fire. “It was bad,” she said, adding it seemed obvious he had poured some sort of accelerant over himself to ignite such huge flames.

The man who set himself on fire Wednesday is being treated in Boston for severe burns and is in critical condition.

Police say Parker doused himself with gasoline in his apartment at 675 Congress St. then went across the street to the statue of Henry Wadsworth Longfellow and ignited himself.

A bystanders used a fire extinguisher to put out the flames and rescue workers took him to Maine Medical Center before he was flown to a Boston burn center, officials said.