An elderly Brooklyn man with a cane turned the tables on a home invader — beating him to death when the robber pushed his way into the senior’s Crown Heights home Sunday, police sources said.

The doomed robber — identified by police as Rodolfo Rosa, 48, of Arlington, Va. — had barged his way into the Union Street apartment of gray-haired Cecil Brown around 10 a.m., cops said.

The tough-as-nails senior resident, who walks with the help of a cane, then used an object from his home to bludgeon the invader during the life-and-death melee that ensued, police said.

Rosa was left with severe head trauma, police sources said.

He was pronounced dead at Kings County Hospital at about 11 a.m., police said.

It was not immediately clear what Brown used to fatally beat Rosa, according to police sources.

Brown suffered only some bumps and bruises in the battle at 1776 Union St., sources said.

He was being treated at Kings County Hospital on Sunday night and is expected to recover, they said.

Police said Brown and Rosa didn’t know each other.

Brown has no prior arrests, cops added.

Law-enforcement sources said there would be little reason to charge Brown with a crime in the case because he appeared to be acting in self-defense.

“It’s looking like a home invasion, that’s it,” a police source said.

A former city prosecutor agreed that the district attorney would have virtually no grounds to charge Brown.

“The cops are right. In your home, this is self-defense,” said the legal-eagle source.

“Deadly force is permitted when you’re inside your home in self-defense.”

Even if prosecutors wanted to go after Brown, they would struggle to get this type of case past any Brooklyn grand jury, the source said.

“No DA would want this case, and a grand jury would likely dismiss it if a bad guy invaded a home,” the expert explained.

It wasn’t clear why Rosa was in the area.

Additional reporting by David K. Li and Leonica Valentine