After three years of bizarre twists and turns, Paul Ceglia’s lawsuit against Facebook has run into a new and perhaps fatal obstacle – a federal judge’s recommendation that it be dismissed.

U.S. Magistrate Judge Leslie G. Foschio ruled against Ceglia on Tuesday in what could be the start of the end for the Allegany County man’s claims that he owns half of the social networking giant.

Foschio, in his decision, ruled that a written contract between Ceglia and Facebook co-founder Mark Zuckerberg is a “recently created fabrication” and recommended that U.S. District Judge Richard J. Arcara dismiss Ceglia’s civil lawsuit.

“Today’s federal court decision confirms what we have said from day one: This lawsuit is an inexcusable fraud based on forged documents,” said Colin Stretch, Facebook’s deputy general counsel, in a statement. “We are pleased the court agrees.”

Filed in 2010, Ceglia’s suit was based on his contention that he and Zuckerberg signed a contract in 2003.

Facebook acknowledges Zuckerberg signed a contract with Ceglia while a student at Harvard University, but the social media giant contends it had nothing to do with Facebook.

In his report to Arcara, who must approve his recommendations, Foschio agreed and went to great lengths in his decision to review Facebook’s case against Ceglia.

“Based on the evidence in the record, it is highly probable and reasonably certain that the [contract] and the supporting emails were fabricated,” Foschio said.

The judge used his 155-page decision to document the wide range of testing and analysis used in the Facebook case, including chemical, handwriting and printing analysis on the alleged contract.

In the end, Foschio said, he found very little in the record to back up Ceglia’s ownership claims.

“Plaintiff’s attempts to corroborate his self-serving assertion that the [contract] is the authentic contract simply fall short,” Foschio said in his recommendations to Arcara.

Foschio went so far as to note inconsistencies with the fonts, typesetting and formatting of the alleged contract and said they “call the document’s authenticity into question.”

The judge’s ruling, nearly three years in the making, could mark the end of a civil suit that has attracted national attention because of Facebook’s immense popularity.

One of Ceglia’s attorneys left the door open Tuesday to an appeal if Arcara adopts Foschio’s recommendations, and he said his client is prepared to continue the legal battle.

“There’s a legitimate claim here,” said Robert Ross Fogg of Buffalo. “Even if the judge rules against Mr. Ceglia, there’s still an appeal process.”

The Facebook case has seen its share of bizarre developments, including a series of court-ordered sanctions against Ceglia.

As recently as December, Foschio ordered him to pay $96,000 to Facebook and Zuckerberg for money it spent on lawyers, experts and travel. That ruling nearly doubled what Ceglia had previously been ordered to pay in court-approved fees and sanctions since the civil case began.

One of Foschio’s sanctions came after Jeffrey A. Lake, one of Ceglia’s previous attorneys, documented his client’s refusal to comply with one of the judge’s orders.

Lake later stepped down, becoming the latest in a long list of lawyers to withdraw from the case.

Dean Boland, who is at least the fifth lawyer hired by Ceglia, also asked to withdraw, but Foschio, citing ongoing delays in the case, refused his request.

At about the same time Boland was asking off the case, Ceglia found himself the target of federal prosecutors in Manhattan looking into the authenticity of his alleged contract with Facebook. He was charged in January with orchestrating a “multibillion-dollar scheme” to defraud the company.

The criminal charges against Ceglia, in many ways, mirror the counter allegations made by Facebook in Ceglia’s civil suit.

The complaint contends that Ceglia replaced the first page of his previous contract with Zuckerberg with a new page doctored to make it appear Zuckerberg had agreed to provide him with an interest in Facebook.