Getty

[1]

Olivia Wilde[2] can breathe a sigh of relief ... a judge just granted a permanent restraining order against the man she claims keeps showing up at her home, believing he was her lover.

According to new legal docs obtained by TMZ ... 30-year-old Eric Nathanial Fuhs must stay away from Olivia for the next 3 years. We're told the restraining order also protects her ex, Jason Sudeikis[3], and their kids.

TMZ broke the story ... Olivia sought protection[4] against Fuhs last month after claiming she had security footage showing him showing up to her crib on multiple occasions to leave notes for her and Sudeikis, with the guy falsely claiming he was dating Olivia.

The documents had initially stated Olivia and Jason still lived together, but sources later said that wasn't the case[5].

Getty

[6]

The actress, who is now with Harry Styles[7], also said Fuhs left an ominous note saying he's "struggling to stay sane."

Olivia said she was scared the man was able to find her home, so she filed for the restraining order.

Read more from our friends at TMZ