The scene outside the apartment building in the 6800 block of Seat Pleasant Drive where police say a man was shot dead and a 2-year-old boy was wounded by gunfire Wednesday morning. (Matt Zapotosky/The Washington Post)

A 25-year-old man who was carrying his 2-year-old son was killed when two attackers ambushed him in his Seat Pleasant apartment building and shot him and the toddler, police said.

The man, Nicoh Mayhew, was supposed to testify against two men at a murder trial early next year, and police are investigating whether he was killed because of his cooperation with prosecutors, law enforcement officials said.

But Mayhew had connections to other crimes, and detectives have not determined precisely why he was killed, said the officials, who spoke on the condition of anonymity to candidly discuss the sensitive, ongoing investigation.

On a day when Prince George’s County officials held a news conference to detail what they called a “historic drop” in killings, the incident reminded them that the problem of violence still exists. Just as the county executive, the police chief and Maryland’s lieutenant governor hailed the decrease in this year’s number of county homicides — 61 — as the lowest total since the mid-1980s, detectives investigated the Seat Pleasant shooting. The boy’s injuries were not believed to be life-threatening.

“Anytime we have any kind of act of violence in the community, it’s bad timing,” Police Chief Mark Magaw said, addressing a reporter’s question about the shooting. “We’ll deal with this and arrest the people involved in it.”

The fatal shooting occurred about 10 a.m. Police said that Mayhew, holding his son, was near or in a doorway at the garden-style apartments in the 6800 block of Seat Pleasant Drive when he was attacked by two men.

Julie Parker, a police spokeswoman, said investigators believe that Mayhew was specifically targeted, but they are still exploring why. She said police were searching for a black, four-door BMW sedan seen leaving the scene and are reviewing footage from traffic and surveillance cameras.

“We know with confidence that this was not a random act of violence,” Parker said.

The law enforcement officials said Mayhew was scheduled to testify against two men — one a friend, the other a relative — who were charged in a double slaying last year in Capitol Heights. Two men were found dead in a car after what investigators believe was a drug robbery. The officials said detectives found evidence of bleach and gasoline — as if someone tried to burn the car and cover up evidence.

Mayhew was believed to have played a role in the coverup, but in exchange for his testimony, he was not charged in the killings, the officials said. He agreed to cooperate in the case against the men charged in the shooting, the officials said.

John Erzen, a spokesman for Prince George’s County State’s Attorney Angela Alsobrooks, confirmed that Mayhew was scheduled to be a witness in a murder trial scheduled for Feb. 19 and added that “the status of that trial now is to be determined as this investigation continues.”

“At this point, we obviously don’t know if that’s why he was killed,” Erzen said.

Police cordoned off a large swath of Seat Pleasant Drive on Wednesday afternoon, keeping neighbors away while homicide detectives moved in and out of the brick building where the shooting occurred. Many residents stood along the yellow crime tape, shaking their heads as they exchanged information about what they heard had happened.

“They need to clean up this area,” said a woman who declined to give her name because the killers remained at large and she feared for her safety. “It’s a lot of drugs going on here in these apartments.”

The scene was far different just minutes earlier at police headquarters, where large poster boards touted 2,240 fewer crime victims in Prince George’s this year compared with 2011, fueled by a 35 percent drop in homicides and a 7.1 percent drop in overall crime. Police displayed pictures of Ronald Reagan and former Washington Redskins player Doug Williams, noting that killings had not been this low in the county since Reagan was president and Williams the team’s quarterback. They credited Prince George’s County Executive Rushern L. Baker III’s Transforming Neighborhoods Initiative — which assigned teams of government officials to monitor six troubled neighborhoods indefinitely.

“If you haven’t realized it by now, there’s a renaissance underway in this county,” Magaw said. “We’re just beginning. We’re just getting started.”

Officials acknowledged that Mayhew’s killing served as a reminder that 61 killings is still too many and that there is still work to be done.

“Knowing that there was a child involved in this should be the motivating factor,” Baker said. “I know it is for me.”

Jennifer Jenkins and Magda Jean-Louis contributed to this report.