If there’s anybody who knows what it’s like to run the District government while dealing with legal problems and other controversies, it’s Marion Barry. So I sought out the man with experience to ask what advice he had for his longtime friend and ally, Vincent Gray, in the new mayor’s time of trouble.

Barry welcomed the inquiry and was fully prepared to respond. Although a limping leg and stiff shoulder betrayed the wear and tear of his 75 years, the four-time mayor and current council member was mentally sharp.

“I am an expert on successfully maneuvering through a crisis,” Barry (D-Ward 8) said at the start of our talk Monday. “I know what the game is.”

Much of what Barry said was pretty conventional and has been said elsewhere. The mayor should have a game plan. Communicate well. Don’t get distracted from the real work of leading the city.

But Barry also sought to cast Gray’s predicament in what I saw as an “us versus them” context, an approach I hope the mayor rejects. He said Gray was the target of sniping by a hostile alliance of the media and a bloc of unfriendly council members. He called the latter the “Fenty Four,” saying they supported former mayor Adrian Fenty, openly or otherwise, in last year’s election.

“That makes it difficult [for Gray]. One of the anchors of managing a crisis is that you can control some things. [But] you can’t control those four council members,” Barry said. “The press is aiding and abetting the Fenty Four by always asking them what they think.”

Barry identified the four as Jack Evans (D-Ward 2), Jim Graham (D-Ward 1), David Catania (I-At Large) and Muriel Bowser (D-Ward 4). He called back Wednesday to say Bowser was telling people that she was going to break with the others, so the number might shrink to three.

Barry pointed to such comments as Evans’s remarks about overspending and Catania’s suggestion that Gray consider replacing his chief of staff, Gerri Mason Hall.

(As it happens, Hall resigned Wednesday afternoon.)

Barry’s analysis is wrongheaded. It’s perfectly natural for Fenty supporters to take the lead in holding Gray and his team accountable for overpaying staff and nepotistic hiring. And it’s not surprising that Gray is feeling heat over allegations by Sulaimon Brown, a minor mayoral candidate, that Gray’s campaign gave Brown a job and cash in return for nasty attacks on Fenty. Gray has denied Brown’s allegations, and The Post has been unable to independently verify any payments.

Council members sympathetic to Fenty never had a stake in promoting Gray’s mayoralty in the first place. The press, obviously, is just doing its job.

Barry’s argument is also mischievous. It effectively urges Gray to copy Barry’s own strategy — employed in numerous past scandals — of rallying popular support by casting himself as a victim of malicious forces out to get him.

That would be counterproductive for Gray. If the mayor succumbed, he would betray his campaign theme, “One City.” It would revive political, geographic and racial divisions that we don’t need.

Instead, Gray should stick to dealing with the substance of the scandals and avoiding political spin. He’s promised to cooperate with investigations into Brown’s allegations. He has taken some steps to deal with the hiring controversies, such as promising to lower the pay of some officials. I hope a new chief of staff will provide sounder political advice than Gray received from Hall.

To Barry, the whole affair smacks of political warfare.

“The game of most situations is for the attacker, the media, the enemy, political opponents, to try to discombobulate you, to try to discredit you, to try to disconnect you from your constituency, to try to disrupt what you’re trying to get done,” Barry said.

Barry wouldn’t tell me what advice, if any, he’s given Gray personally on handling the scandals. “It’s like boxing. You don’t telegraph your punches,” he said.

He dismissed the idea that the controversies are reminiscent of problems in his terms as mayor.

“Let’s take something like corruption,” Barry said. “You probably can find [only] four or five top people” who were guilty of wrongdoing during his administrations, he said. That would be four or five out of about 40,000 city employees who worked for him.

“You may have had some people at inspection stations taking a little bit of money here for passing inspections. But that wasn’t prevalent in my administration,” he said.

As for current complaints about nepotism in hiring, Barry didn’t see anything wrong with it. He referred to a quote that he’d heard attributed to a Chicago mayor: “If a man can’t help his son, who’s qualified to do something, he doesn’t deserve to be a father.”

Barry added, “That’s my philosophy.”

I discuss local issues at 8:51 a.m. Friday on WAMU (88.5 FM).