From his office door a few yards from historic Howard Theatre, James Patterson, a maintenance man in the District for more than 50 years, has celebrated his neighborhood’s evolution from crime-ravaged blight to gilded renewal.

Yet a recent rash of gun violence in Shaw, as the neighborhood is known, suggests the transformation is far from complete, with each new round of bloodshed evoking the carnage that defined the area a generation ago.

“I’m just hoping it doesn’t scare people away,” Patterson, 79, said as he sat with friends on the sidewalk in front of his cluttered cubbyhole of an office on T Street NW. “I thought all the changes would make a difference and everyone would be on the same page. But it doesn’t look like it’s going that way.”

Over the past two decades, as American cities rebounded after decades of neglect, no neighborhood embodied Washington’s revival more than Shaw, just north of downtown, with its thicket of new gleaming towers, health clubs and hipster-happy cafes and restaurants.

A once predominantly black neighborhood that was ravaged during the 1968 riots, Shaw is now a magnet for a multiracial spectrum of affluent professionals migrating to $1 million homes, apartments that rent for $3,000 and $4,000 a month, and restaurants with names such as “Southern Efficiency” and “Eat the Rich.”

James Patterson, 79, a maintenance man, poses for a photo inside his store half a block from the Howard Theatre, where he used to be the janitor, in the Shaw neighborhood in Washington. (Astrid Riecken/For The Washington Post)

Yet, for all its newfound affluence and diversity, the neighborhood remains the terrain of an entrenched population of poor and working-class residents who inhabit pockets of subsidized housing along the Seventh and Ninth street corridors.

While violence has long been part of the neighborhood’s narrative, Shaw’s shifting fabric has made the most recent rounds more confounding, particularly for longtime residents who remember the open-air drug markets that proliferated during the crack epidemic of the 1980s and 90s.

In those years, residents could largely attribute the mayhem to fighting between rival drug gangs. They are uncertain what is driving the current spasm of shootings, the victims of which have included a recent American University graduate and a 31-year-old mother who were struck by stray bullets.

“Before it was battles over turf and drugs,” said Stanley Mayes, 65, co-owner of Divine Shine, a T Street shoe repair shop. He has lived in Shaw for decades. “Now it could be a dispute over any number of things. Before you could settle a dispute with fists. Now it’s four gunshots to the torso.”

The near-endless stream of ribbon cuttings, groundbreakings and grand openings in recent years focused attention on Shaw’s renaissance. The long-vacant O Street Market — the site of a 1994 shooting that resulted in a teenager’s death and the wounding of eight others — was reborn as luxury apartments and a refurbished Giant supermarket that offers an ample wine selection and a WiFi cafe.

The renewal unfolded as the number of violent crimes declined across the city, including in the 3rd District, which includes Shaw. In 1997, police logged 38 homicides in that district; by 2012, the number fell to five. The number of assaults declined from 762 to 352 during the same period.

But even as crime in Shaw declined, and more affluent residents arrived, aspects of the neighborhood’s social and economic dynamics remained constant. The gangs that were well known in the area — loose-knit crews with names such as “Seventh and O” and “Fifth and O” — never went away.

“The setting has changed, the vacant buildings are occupied, and the vacant land is built up, but no one has addressed the underlying problems here,” said Martin Moulton, a Shaw activist who lives on Fifth Street NW.

Eighteen months ago, he recalled by way of example, he dove from his bed to the floor after gunfire erupted outside his window. “It’s an undeterred stream of violence,” he said. “No one has stopped anyone from feeling like they can come into the neighborhood and freely shoot people and get away with it.”

Ibrahim Mumin, 68, a development consultant who has lived on Sixth Street NW since 1976, struggles to make sense of the violence. But he said he detects a percolating tension resulting from the economic chasm between Shaw’s new arrivals and poor and blue-collar residents.

“Outsiders may not see it, but I get a sense of anger among younger African American males,” he said. “It’s that old story: If you have a barn full of corn and I have a barn that’s empty, at some point you’re going to have a problem.

“What’s making people sharp,” he said, “is that someone has some money, and it’s not me.”

‘I just don’t feel safe’

The most recent homicide in Shaw to draw widespread attention was the killing of Matthew Shlonsky, an American University graduate who was struck by a bullet intended for someone else as he exited a taxi on Seventh Street NW on Aug. 15.

At that point, Mayor Muriel E. Bowser (D) and police officials already were scrambling to contend with escalating violence across the city, much of it occurring in the District’s poorest neighborhoods east of the Anacostia River.

Four days before Shlonsky’s killing, gunfire wounded three people at Seventh and O Streets NW. A block away, Tamara Gliss, 31, a mother, was killed by a stray bullet at an evening barbecue over Memorial Day weekend.

It was around then that Kimberly Robinson, 31, the owner of a small dessert-catering business, moved from the 14th Street corridor to Shaw. When she was looking for a new place, Robinson considered Columbia Heights but was put off after a stabbing outside the building she was eying. Instead, she chose a two-bedroom apartment on Ninth Street NW.

Robinson soon found herself debating friends about whether the explosions she heard as she sat on her balcony at night were fireworks or gunshots. She noticed an “immeasurable uptick” in the alerts on her smartphone reporting shootings and robberies around Seventh and O streets.

Then, in late July, she learned from a neighborhood bartender that a stray bullet had punctured an apartment window at the new luxury development known as City Market at O, where two bedrooms rent for as much as $4,400. (The tenant was not home at the time.)

Robinson understands that city life is learning to “take the good with the bad.” But she decided to no longer walk to Seventh Street NW after dark. There would be no more nocturnal visits to the Giant or the bars and restaurants along that corridor that had helped lure her to Shaw.

“I won’t go over there,” she said. “I just don’t feel safe.”

Ray Milefsky, 66, a retired State Department analyst, is accustomed to taking precautions.

Since paying $48,000 for a rowhouse near Eighth and Q streets in 1986, Milefsky has slept in the rear of his home to avoid stray bullets that he fears could strike the front of his building (a bullet once sliced through his glass entrance).

The neighborhood’s new prosperity has not made him any less careful. He rejected a neighbor’s recent suggestion that he remove the steel bars from his windows. He also expressed wariness about benches recently installed across the street in a triangular park memorializing the historian Carter G. Woodson. Years ago, Milefsky recalled, he and a friend removed a previous set of benches from the patch because they had become an encampment for drug dealers and prostitutes.

The recent spasm of violence, Milefsky said, creates a sense of “deja vu all over again, only now it’s in a tonier setting.”

“When the crack dealers were around, it was par for the course, but I knew them and they knew me,” he said. “Now it’s an amorphous kind of crime, and no one has a handle on it. It was an unsafe neighborhood, and it still is.”

Around the corner, Ben Carver, 39, an artist and photographer who has rented an apartment on Rhode Island Avenue for eight years, said the neighborhood feels far safer. When he arrived, he said, the Metro station across the street was a magnet for muggers targeting commuters. Twenty yards from his front door, he saw a man collapse from a bullet wound.

In those years, he would never have considered walking along Seventh Street after dark. “It’s a totally different place now,” he said. “I haven’t heard a gunshot since I don’t know when. I walk everywhere I want. I have no issues — day or night.”

A few blocks away, Curtis Mozie was at a table in the cafe at the Giant.

As much as anyone, Mozie, an amateur videographer who has documented the lives of dozens of homicide victims from Shaw, knows the neighborhood’s violent history and how some periods can be worse than others.

The mid-1990s was horrific, he said, “then it quieted down.” More recently, he said, Shaw was “on a roll,” and he found himself hopeful that the carnage “was in the past.”

Then, six weeks ago, a friend was stabbed to death in a building across from the Giant, and Mozie found himself in mourning once again.