Judgment of the Supreme Court, *393New York County (John Byrne, J.), rendered on June 6, 1989, convicting defendant, following his plea of guilty, of attempted criminal possession of a weapon in the third degree and sentencing him to five years’ probation, is unanimously reversed on the law, the plea and sentence vacated and the matter remanded for further proceedings.
Defendant was arrested as the result of an incident which occurred on September 20, 1988 at L’Tropical restaurant in the Bronx in the course of which he displayed a knife, swung it at the victim, then took out an operable .22 caliber revolver and threatened the victim with it. It appears that the People originally proposed a preindictment plea to an E felony with a sentence of probation. However, since defendant did not promptly respond to the offer, the matter was thereafter presented to the Grand Jury, which returned an indictment on February 6, 1989 charging him with criminal possession of a weapon in the second degree, a class C violent felony offense, criminal possession of a weapon in the third degree, criminal possession of a weapon in the fourth degree and two counts of menacing. On March 13, 1989, defendant withdrew his previously entered plea of not guilty and pleaded guilty under the first count of the indictment to attempted criminal possession of a weapon in the third degree, a class E felony, with the proviso that he receive a sentence of five years’ probation. Two days later, prior to sentencing, the District Attorney moved to have the plea set aside on the ground that the plea to an E felony was unauthorized since, pursuant to CPL 220.10 (5) (d) (ii), a class C violent felony offense could only be reduced to a class D violent felony offense. Yet, notwithstanding the vehement insistence of the prosecutor that defendant’s plea was illegal and despite his proposal that defendant instead plead to a class C felony with a minimum sentence of 1 Vz to AVz years’ incarceration, the court, evidently persuaded by defense counsel’s argument that the People had "de facto” accepted the plea arrangement, denied the prosecution’s application and sentenced defendant to five years’ probation. In the view of the court, a term of imprisonment would be unduly harsh.
The law is established that a court possesses inherent power to correct its own error by vacating an unlawful sentence or plea (People v Wright, 56 NY2d 613; People v Minaya, 54 NY2d 360, cert denied 455 US 1024; People v Bartley, 47 NY2d 965). Where the court has clearly been apprised of the illegality prior to the commencement of the service of sentence, it is certainly error for the court nonetheless to decline to set aside *394the unauthorized plea or sentence (see, Matter of Campbell v Pesce, 60 NY2d 165 [in which the Court of Appeals held that the trial court could not vacate the illegal plea and reinstate the original charges since defendant therein had already begun serving his sentence]). In the instant matter, in contrast, the court was advised of the unlawfulness of the plea even prior to the imposition of sentence, and, moreover, the People objected to the terms of the plea "agreement”. Under these circumstances, defendant’s plea should have been treated as a nullity. Accordingly, the plea and the sentence are vacated, and the matter is remanded for further proceedings. Concur—Kupferman, J. P., Sullivan, Carro, Milonas and Smith, JJ.