Paul Ceglia’s lawsuit against Facebook took a bizarre turn Friday – he’s now the one accused of wrongdoing.

Ceglia, the Allegany County man who claims to own half of the social networking giant, was charged in federal court in Manhattan with orchestrating a “multi-billion-dollar scheme” to defraud the company,

Federal prosecutors claim Ceglia “doctored, fabricated and destroyed evidence” to support his ownership claims regarding Facebook, and charged him with felony wire and mail fraud.

He was arrested by U.S. Postal Inspection Service agents at his home in Wellsville Friday morning and arraigned Friday afternoon in Buffalo federal court.

“Ceglia’s alleged conduct not only constitutes a massive fraud attempt, but also an attempted corruption of our legal system through the manufacture of false evidence,” U.S. Attorney Preet Bharara of Manhattan said in a statement. “That is always intolerable. Dressing up a fraud as a lawsuit does not immunize you from prosecution.”

Ceglia claims he signed a contract with Facebook co-founder Mark Zuckerberg in 2003 that entitles him to a stake in the company.

Zuckerberg acknowledges signing a contract with Ceglia while he was a student at Harvard University but maintains the deal had nothing to do with Facebook.

The government’s criminal complaint against Ceglia comes to the same conclusion as Facebook – his claim of ownership is entirely false.

“They are clearly trying to fight the civil case with everything they have, including this criminal complaint,” Ceglia said in court Friday.

He was ordered detained by U.S. Magistrate Judge Jeremiah J. McCarthy, who gave the government until Monday to get a court order requiring he be kept in custody until his next court appearance in Manhattan.

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

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

“Ceglia used the federal court system to perpetuate his fraud and will now be held accountable for his criminal scheme,” Orin Snyder, a lawyer for Facebook, said in a statement.

Prosecutors, when asked by McCarthy about the similarities in the civil and criminal cases, acknowledged them but said the government conducted its own investigation of Ceglia’s alleged fraud.

“The government has substantial evidence that the defendant has falsified documents, falsified contracts and falsified emails,” Assistant U.S. Attorney Aaron J. Mango said Friday.

Mango also suggested that Ceglia was a flight risk because of his dual citizenship in Ireland, a prospect Ceglia’s lawyer tried to refute by handing over his U.S. and Irish passports.

“There’s nothing to suggest he’s going to flee Wellsville, his home,” said Assistant Public Defender Daniel P. Greene.

The criminal charges against Ceglia are the latest chapter in a legal case that has seen its share of odd twists and turns.

To date, Ceglia has been hit with about $98,000 in court-ordered sanctions in the civil case, most of them attorney fees claimed by Facebook’s lawyers.

The latest sanctions stem from Ceglia’s apparent refusal to release the so-called Kasowitz letter, a confidential document from the New York law firm of Kasowitz, Benson, Torres & Friedman to two other firms, DLA Piper and Lippes Mathias Wexler Friedman of Buffalo.

All three are law firms that once represented Ceglia in the Facebook case. At least four law firms have signed on and then withdrawn from Ceglia’s ownership suit since it was filed two years ago.

The letter reportedly includes information advising DLA Piper and Lippes Mathias that Kasowitz is withdrawing from the case because of a determination that the Ceglia-Zuckerberg contract is a fraud.

And they were not the first firm to drop Ceglia as a client.

In May, just three months after joining the suit, Milberg LLP became the fourth firm to sign on and then withdraw from Ceglia’s ownership suit.

Dean Boland, who continues to represent Ceglia, joined the case in 2011 after Ceglia’s previous attorney, Jeffrey A. Lake, stepped down.

Lake, a San Diego lawyer, left the case just days after he and another lawyer documented Ceglia’s refusal to comply with a court order by U.S. Magistrate Judge Leslie G. Foschio. Ceglia was later sanctioned by Foschio.