Bun B didn't just defend his wife and home when a masked man with a gun tried to rob them ... we're told he chased the guy down and unmasked him to make sure his ass was going to jail.
The Houston rapper's lawyer, Charles Adams, tells TMZ ... Bun and his wife, Queenie, met with the District Attorney this week to discuss the incident, and they have been reassured they are being treated as victims in the case.
We're told everything they've reported lines up with law enforcement's investigation, and the suspect, Demonte Jackson, is facing 3 first-degree felonies -- 2 counts of aggravated robbery with a weapon and one count of burglary.
Adams tells us Bun B wasn't specifically targeted by the intruder -- he was going house to house in the neighborhood and Bun's wife happened to answer the door.
We broke the story ... Queenie offered up her Audi in the garage to the suspect, which is where Bun confronted him and a gunfight ensued. Adams says after the man escaped and left his gun behind ... Bun hopped in his car and pursued him.
We're told the rapper caught up and held the guy at gunpoint ... then made him take off his mask so he could identify him. The suspect then escaped again.
As we told you, Jackson showed up at a Houston-area hospital several hours later with a gunshot injury to his shoulder. He was treated and arrested.