Mel B just got her former nanny out of her hair for 5 years ... because she just got a restraining order that will keep her away.
Mel B's lawyer was in court Wednesday, armed with a declaration from Mel claiming Lorraine Gilles has harassed her. She's the nanny whom Mel claims had an affair with husband Stephen Belafonte and even got pregnant by him. Mel B also claims Gilles is holding her sex tapes hostage.
Mel claims Gilles has been verbally abusive toward her, disrespecting her and rolling her eyes during conversations. Mel B also says she would make "exacerbated sounds" designed to annoy her. She also says Gilles would call Mel B's kids her kids.
TMZ broke the story ... Gilles has sued Mel B for defamation, claiming she did not have an affair with Belafonte or get pregnant by him. She says Mel B seduced her into having 3-ways for 7 years. Our sources say Mel B acknowledges the 3-ways, but she says it was at Belafonte's insistence.
The restraining order is in effect for 5 years.