MARTINEZ — Minutes after being released from jail in a pending felony gun case, the Bay Area rapper A-Wax publicly declared his innocence, adding that he plans to fight his criminal case and pursue civil action against the officers who raided his Pittsburg music studio last month.

A-Wax, whose born name is Aaron Scott Doppie, was freed from jail Tuesday afternoon, more than 24 hours after a Contra Costa Superior Court judge ordered him to be released. For a month, Doppie was held at the Martinez Detention Facility on a bail that topped $1 million, for charges of possessing a gun, ammunition, and a large-capacity magazine.

But in an exclusive interview Tuesday, Doppie, 40, said that he had never even seen the gun that was allegedly discovered by Pittsburg officers, who arrested him March 10 in an early-morning raid of his studio. Doppie said he’s “completely confident” that DNA or fingerprint tests will exonerate him, and that he believes the firearm was brought into the studio by one of the more than a dozen other people he says had entered without his knowledge that day.

“I’ve been racking my brain … I’m just regrouping and trying to reflect and see what I could have done different,” Doppie said. “Maybe I just gotta slow down on taking chances on some people, especially giving out keys to the building. I definitely made a mistake in that I gave out too many spare keys to people and they were letting in their own people.”

He speculates that’s how the gun found its way into the studio, but says he went to bed early that night and had no idea a firearm was present until after his arrest.

“I tell all the youngsters when they come and go, I don’t want no guns, no firearms, no crazy drugs, anything coming in my doors, but that’s easier said than done,” Doppie said. “I don’t pat-search people down or have a metal detector or a metal wand when they’re coming through.”

At Doppie’s first court appearance last month, prosecutors revealed that he was arrested in connection with an unspecified murder investigation. Doppie said he was befuddled by the arrest, and refused a police interview. To date, he has not been charged with murder, and police have not commented on the investigation other to say that it is ongoing.

“When they brought me in they wanted to question me and I had no idea what they were talking about so I just asked for a lawyer,” Doppie said. “I have no idea what they were even asking about.”

Doppie said that during the course of his rap career — which has spanned 20 years — he has worked with “at-risk youth” and tried to steer youngsters away from making the same mistakes he made as a teen and young adult.

“When I was young, I didn’t have these kind of opportunities and that’s what led me to going to jail … I had no outlet or no big brothers or older friends or homies of mine who were trying to teach me a better way,” Doppie said.

He later added: “I’ve been doing this for a long time and maybe for every 10 people I do this with it works with two or three or maybe just one sometimes. It’s been like my life’s work basically, this is where I get most of my fulfillment. I’m really just trying to see if i can save some people from going through the same mistakes and hardships I did.”

In his music and interviews, Doppie has been open about legal troubles in his youth. At 16, he was charged with murder as an adult in Washington, and served a five-year prison term after taking a plea deal on a manslaughter charge. In 2001, he was convicted of a felony residential burglary. While serving time in prison, he participated in music programs and taught himself to write raps. Since the early 2000s, he’s put out dozens of albums and mixtapes, and still releases songs that garner millions of plays online.

But those decades-old convictions are coming back to haunt Doppie, who could face life in prison under California’s Three Strikes Law if he’s convicted as charged in his pending gun case. He said he’s ready to take his case to trial, and in the meantime is exploring civil options over his raid. He said officers destroyed his property, including security cameras he kept around his studio.

“I can’t tell you (law enforcement’s) motives, I can just tell you from my side of things, I just feel targeted because of my celebrity in that town, so to speak,” Doppie said. He added that while he was booked in the jail, “The older cops would tell me all the younger cops are big fans of my music, so I took it that the people talking to me weren’t fans of my music…From my vantage point it feels like I’ve been targeted because I’m a rapper of some success.”