A North Carolina man’s conviction on charges of conspiracy and racketeering has been tossed by a federal appeals court because his lawyer apparently snoozed during trial.

The U.S. Court of Appeals for the 4th Circuit in Richmond overturned Nicholas Ragin’s 2006 conviction and 30-year prison sentence, ruling that he had been denied his Sixth Amendment right to counsel.

Ragin claimed his court-appointed attorney, Nikita V. Mackey, nodded off as many as 20 times during trial, closing his eyes and even snoring on occasion.

“Based on this record, we find it impossible not to conclude that Mackey slept, and was therefore not functioning as a lawyer during a substantial portion of the trial,” Judge Roger Gregory wrote in an opinion issued Friday.

In 2004, a grand jury in the Western District of North Carolina indicted Ragin and six others for conspiracy, among things, in connection with drug and prostitution rings, according to court documents.

Mackey, a former police officer and state legislator in North Carolina, was appointed to represent Ragin in the case, according to news reports.

After the conviction, Ragin sent a handwritten letter to the district court, complaining that his lawyer “had the audacity to fall asleep ‘twice’ during the trial,” according to court documents. Then, in 2010, Ragin filed a petition to have his conviction and sentence overturned, claiming that he had been denied proper legal assistance.

Ragin said his lawyer slept numerous times and claimed that at least once, “Mackey asked Ragin what he missed,” according to the court documents.

At a hearing for Ragin’s petition, according to documents, a juror testified that the lawyer slept “almost every day” for “30 minutes at least” each time.

Mackey told The Washington Post in a statement that “the allegations against me regarding this case are untrue” and are the result of a political battle.

“I understand and expect for defense counsel to do anything within ethical bounds in order to defend their clients,” he said. “I would do the same. I have no problem with appellants’ counsel using any argument that they feel will prevail. But, to imply that a presiding federal court judge would allow defense counsel to ‘sleep almost every morning and afternoon’ ‘for 30 minutes’ as was reported, and do nothing, is ridiculous, and in my view, offensive to the judge and to me.

“I will leave it to each person to form their own opinions as to how realistic that is.”

According to the court documents, Peter Adolf, another attorney who was at the 2006 trial, testified to Ragin’s claims, recalling a government attorney who “approached Mackey to show him an exhibit that they intended to introduce.”

The prosecutor, Adolf said, “walked over to Mr. Mackey, and I remember that Mr. Mackey was sort of sitting back, leaning back in his chair with his left elbow on his left thigh … and sort of with his chin resting on his fist.”

The government lawyer, Adolf said, held a document in front of Mackey, “and he didn’t move, he sort of sat there. Judge Conrad leaned into his microphone, because we were all sitting there and [Mackey] wasn’t moving and said, ‘Mr. Mackey’ … very loudly.”

Adolf said Mackey “jumped up and sort of looked around and was licking his lips and moving his mouth and looked sort of confused and looked all over the room.”

Mackey did not dispute allegations that he slept during trial.

This is not the first time Mackey has gotten into trouble.

In 2003, he resigned from the Charlotte-Mecklenburg Police Department while he was under investigation; he later said he had stepped down to spend time preparing for the bar exam to become an attorney, according to a report in the Charlotte Observer.

Several years later, he was elected Mecklenburg County sheriff — but a state Democratic review panel overturned his nomination over voting issues.

Mackey was also sued by publishers of a phone book, which claimed he failed to pay more than $22,000 in advertising debt, according to the newspaper.

In 2008, Mackey was reprimanded by the North Carolina State Bar for “failing to appear in court” and “adequately communicate” and for collecting a fee from his client that was “excessive,” according to the documents.

He was reprimanded again the next year.

In 2010, he was suspended for three years because he did not disclose to the bar that he had failed to pay federal and state income taxes, that he had been suspended from the police department and that he had been under police investigation, according to the documents.

However, he was reinstated the next year.

A North Carolina State Bar spokeswoman said no public discipline has been issued in the Ragin case.

Mackey said that the allegations against him are the result of “the most contentious political battle for Sheriff in Charlotte, North Carolina’s history.”

“I have come to expect that some people and various media outlets will distort my record and/or actions as result of the tensions that emerged from that contest,” he said in the statement, “but I am not use to attorneys’ disparaging a federal court judge in this way.”

Mackey added that he is glad his client’s appeal was successful.

“I wish him well,” he said.

A federal judge had initially denied Ragin’s petition.

It was appealed to the 4th U.S. Circuit Court of Appeals, and a three-judge panel from that court vacated the conviction and sentence, setting a precedent for federal cases in the Carolinas, Virginia and West Virginia, according to reports.

Federal appeals courts have seen similar cases in the past.

The Wall Street Journal reported:

Four other federal appeals courts have held that a new trial is warranted when a lawyer sleeps through “a substantial portion” of his client’s trial or dozes off at a critical moment.

The U.S. Supreme Court, in a 1984 case called Strickland v. Washington, said a defendant must show that a lawyer’s performance was so miserable that it likely affected the outcome of a trial.

The high court allowed, however, that in rare cases “counsel’s incompetence can be so serious that it rises to the level of a constructive denial of counsel” and automatically scuttles a conviction.

The court reversed the order denying Ragin’s relief.

“We hold that a defendant is deprived of his Sixth Amendment right to counsel when counsel sleeps during a substantial portion of the defendant’s trial,” Gregory wrote in the opinion. “The Sixth Amendment guarantees a criminal defendant the assistance of counsel for his defense.”

This story has been updated.