LONG BEACH — A man described by neighbors as a mentally disturbed hoarder was in custody Thursday after allegedly shooting a code enforcement inspector in the face and firing at police during a seven-hour standoff.

The incident began shortly before 8 a.m., when Long Beach code enforcement officials arrived at the suspect's home - on North John Avenue near 61 st Street in North Long Beach - with a cleaning crew to remove debris from the property, said Long Beach Police Chief Jim McDonnell.

Code enforcement authorities asked for a police officer to accompany them as they served a warrant to deal with hoarding conditions inside and outside the home, McDonnell said.

No one made it inside the house, however, as the suspect opened fire from just inside his front door, striking the code enforcement inspector - who was on the porch - in the head, the chief said. However, the victim was in good condition Thursday and was expected to make a full recovery, McDonnell said.

"The bullet grazed the (victim) near the eye," McDonnell said.

As the patrol officer rushed the bleeding victim to a nearby hospital in his squad car, dozens of backup units flooded the area and the SWAT team was called in, the chief said.

Also on hand were San Bernardino County and Los Angeles County bomb squads.

What unfolded from that point was a tense waiting game interspersed with bursts of gunfire as the suspect, who was thought to be armed with a rifle equipped with a scope, took aim at officers at 11 a.m. and again at 2 p.m., blasting out the window of a city vehicle, the chief said.

The last volley of gunfire occurred as Long Beach SWAT officers fired a mixture of tear gas and pepper spray into the home.

As they shot the gas cannisters into the house, the San Bernardino County bomb squad used its ballistic tactical vehicle, a high-tech armored tractor, to pull shrubbery off the the front of the home and to remove the front windows, bars and a security gate.

"That vehicle took three rounds as it approached the residence," the chief said, adding that the officer driving the unit wasn't hit.

Officers surrounding the small white, one-story house returned fire, but no one was hit by any of the rounds, said Sgt. Aaron Eaton, a Long Beach Police Department spokesman.

The suspect was taken into custody after he emerged from the home a short time later. He refused police orders to surrender and was taken down by a Long Beach Police Department K9 dog, Eaton said.

Police didn't release the suspect's name Thursday, but information from neighbors and property records indicated his name is Anthony Gorosme. According to property records, the home was last listed as owned by Teresa Gorosme, who neighbors said was the suspect's dead mother.

As the bushy-haired and shirtless Gorosme was led handcuffed to a patrol car, he shouted at a group of reporters and photographers, "Tell me you love me."

He was taken to a local hospital to be treated for minor injuries caused by the dog before he was to be booked into the city jail, McDonnell said.

The suspect faces a charge of attempted murder and possible weapons violations, the chief added.

After the arrest, the chief spoke to media at the scene and thanked the outside law enforcement agencies that helped in the peaceful end to the standoff, as well as many other city departments, including the Long Beach Fire Department, the Long Beach Unified School District and the city's Public Works Department.

He also credited his officers with showing remarkable restraint throughout the lengthy ordeal and thanked residents in the area for their patience.

"We are very fortunate here," the chief said. "The outcome could have been much different, much more tragic."

The suspect, McDonnell said, was a source of numerous complaints for code violations and the city had tried to work with him for several years to reduce the blight in and around the property.

Several neighbors described Gorosme, who they all knew as Tony, as a nice man who struggled with mental issues. He was raised in the home since the age of 7 and was cared for by his mother until her death about a year ago, neighbors said.

Though Gorosme often appeared unkempt, he was very friendly and loved to talk to everyone, particularly children, they said.

Neighbor Theodore Guzman said the suspect's mental state seemed to worsen, as did the state of the property, after the death of his mother a year ago.

"Losing his mom was hard. He would tear up when he talked about her (and about) the city taking her things," said Guzman, who has lived in the area for more than 10 years.

Her death was followed by the loss of a stepsister a couple of months later, and his stepfather died about two months ago, said neighbor Tanya Michelle.

"He has no family left, he has nothing to lose," Michelle said as she stood with family and friends near 61 st Street and Rose Avenue waiting and watching the scene unfold.

It was only the day before that Gorosme was showing neighbors a letter from the city warning that action would be taken against the code violations on his property, she said.

"He made it very clear ... they were going to have to kill him," she said. "He said he would not let the police take him away."

Another neighbor, who lives kitty-corner to the suspect, said she was waiting for a friend to go to an exercise class and was warming up outside when she saw the code enforcement officials and cleaning crews arrive.

She waved at Gorosme and turned to stretch, she said, when the first set of shots rang out, prompting her and several city workers to dive for cover.

She and other neighbors tried to talk to the suspect and called him several times, leaving long messages on his answering machine in the hope that he would pick up the phone. The line was disconnected by about 2 p.m., they said.

All of the neighbors said the home was stacked floor to ceiling with furniture and other items that belonged to the man's mother and other relatives, as well as trash. Debris also littered the outside of the house, including several cars, some of which didn't run.

Mailman Mickey Gan, who said he tried to help Tony clean his property more than once, described how the suspect used small, dark tunnels from the front door to various rooms in the house to move around.

"He was very lonely," Gan said. "Ever since his mom (died), he had a very hard time."