EXCLUSIVE

Michael Avenatti's new legal woes -- being accused of extortion and fraud -- could derail the case against R. Kelly ... that's what the singer's lawyer thinks.

R. Kelly's attorney, Steve Greenberg, tells TMZ ... now that Avenatti has been charged with extortion as well as bank and tax fraud, his credibility is now a centerpiece in the singer's case -- specifically, the circumstances surrounding how prosecutors obtained a key piece of evidence.

That evidence, of course, is a sex tape that Cook County investigators claim shows R. Kelly having sex with an underage girl, who's alleged to be 14 years old. It's what many believe to be a smoking gun against R. Kelly ... and the catalyst that led to a 10-count indictment.

Greenberg says the issue of "chain of custody" -- how Cook County got hold of that tape via Avenatti -- is now questionable. Greenberg strongly suggests the possibility the tape could've been altered before it got to prosecutors.

Sources connected to the case tell us that the man who handed the tape over to Avenatti is a whistle-blower who has a history of extorting R. Kelly.

We're told the man recently confessed to prosecutors in Chicago that he squeezed about a million dollars out of R. Kelly's team in the past to stop the tape from going public. So, the question ... if the guy got the cash, how would Avenatti have gotten it?

Remember, there were supposedly TWO R. Kelly sex tapes that Avenatti turned over to Cook County officials, but Greenberg tells us he's only aware of one.