When a man and his attorney parted ways on whether to take back a guilty plea, a judge should have assigned the man a new lawyer rather than deny the motion to withdraw, a Brooklyn appellate court said.

“The defendant’s right to counsel was adversely affected when his attorney took a position adverse to the defendant’s with respect to that branch of the defendant’s motion,” a unanimous panel of the Appellate Division, Second Department ruled on Jan. 22 in People v. Duart, 2010-03955.

The unsigned ruling offered no opinion on the merits of the withdrawal bid, but sent the motion back to Suffolk County Court for a new hearing with a new attorney.

In the underlying case, Douglas Duart faced a 2010 charge of attempted use of a child in a sexual performance and entered a guilty plea in November 2010. Duart had been convicted a year earlier for attempted use of a child in a sexual performance and received probation.

Prior to his January 2011 sentencing, Duart contacted his assigned counsel, Craig McElwee of North Babylon, who was the third attorney to handle the case.

As McElwee would later tell Suffolk County Court Judge Barbara Kahn (See Profile), just prior to sentencing, Duart wanted to withdraw his plea, thinking he did not have enough time to evaluate the offer. Duart also thought he had a “good chance” of acquittal if the case went to trial.

According to the transcript of the sentencing, McElwee said he told his client he thought it was in his “best interest to maintain his plea.” But Duart insisted on withdrawing his plea and indicated in later correspondence that he thought McElwee would represent him at trial.

But McElwee told the judge that based on his client’s “reasoning behind his decision to withdraw his plea, I don’t feel that I could represent him at any further proceedings, as my assistance to him would be in question.”

McElwee said he would “assist in any way” if Kahn permitted the withdrawal of the plea and appointed another assigned counsel. But Kahn noted that Duart had had the benefit of legal advice from multiple attorneys and said “these matters have been ongoing for many, many, many, many months.”

She denied the application from the bench and proceeded to sentencing.

Among other things, Duart lost probation and received a three- to six-year sentence for the 2010 charge. He appealed his convictions and the revocation of probation.

Duart, 49, was released on parole in September.

In its ruling, the Second Department said Kahn “should have assigned a different attorney to represent the defendant before [she] determined that branch of the defendant’s motion.”

When making the ruling, the court held the appeals in abeyance pending resolution of the withdrawal motion.

Justices Peter Skelos (See Profile), Cheryl Chambers (See Profile), Sandra Sgroi (See Profile) and Sylvia Hinds-Radix (See Profile) decided the case, which was submitted for decision on April 3, 2013.

Steven Feldman of Feldman & Feldman in Uniondale represented Duart on appeal.

Suffolk County Assistant District Attorney Thomas Constant appeared for the prosecution.

Feldman and a district attorney spokesman did not respond to a request for comment. McElwee also did not respond to a request for comment.