Roman Polanski was just dragged into the case involving a 1968 Playboy Playmate who allegedly shot her husband in the back two months ago.

Officials believe Polanski may have given her the gun 30 years ago, TMZ has learned.

Here's where it gets creepy.

Sources close to the case tell TMZ, it all started back in 1969, the night before Charles Manson orchestrated the infamous murder of Sharon Tate, Polanski's then wife.

We're told Playmate Angela Dorian, currently in custody for the attempted murder of her husband in October,  was close friends with Tate -- and they even spent the evening together before the slaughter.

After Tate was killed, the famous director was so worried about Dorian, he gave her his handgun for protection, a Walther PPK .380, just like James Bond, sources tell TMZ.

Fast forward 31 years.

Sources tell TMZ investigators believe Dorian used the very same gun to shoot her husband after an argument turned violent.

Dorian faces up to life in prison if convicted.