OPINION OF THE COURT
Memorandum.
The judgment of the Appellate Division dismissing the petition should be affirmed.
The extraordinary remedy of prohibition lies only where there is a clear legal right, and only when a court acts or threatens to act either without jurisdiction or in excess of its authorized powers in a proceeding over which it has jurisdiction (Matter of Rush v Mordue, 68 NY2d 348, 352; Matter of State of New York v King, 36 NY2d 59, 62). Even in those rare circumstances where an arrogation of power would justify engaging the judicial process in collateral intervention and *735summary correction, the writ of prohibition does not issue as of right but only in the sound discretion of the court (Matter of Rush v Mordue, supra, at p 354; La Rocca v Lane, 37 NY2d 575, 579). Plainly the court had jurisdiction to entertain the criminal actions before it and the authority to issue orders relating to the disposition of those actions. Prohibition is generally not available to collaterally review an arguable error of law committed in a pending criminal action (Matter of Gold v Gartenstein, 54 NY2d 627; Matter of State of New York v King, supra) or to challenge an illegal sentence (see, People ex rel. Pritchard v Harris, 82 AD2d 842, lv denied 54 NY2d 608). Our determination today should not be read as passing in any way upon the merits of petitioner’s contention that the court has acted improperly, for we merely hold that the extraordinary writ of prohibition is an inappropriate means to address the claimed error.
Nor is it appropriate in the procedural posture of this case to convert this special proceeding to a declaratory judgment action where the District Attorney’s office, an integral participant in the underlying criminal actions (see, e.g., CPL 220.10) and an entity with a significant interest in this proceeding, is not before the court (CPLR 103 [c]; cf. Matter of Morgenthau v Roberts, 65 NY2d 749, 751; Matter of Morgenthau v Erlbaum, 59 NY2d 143, cert denied 464 US 993).
Chief Judge Wachtler, and Judges Simons, Kaye, Alexander, Titone and Hancock, Jr., concur; Judge Bellacosa taking no part.
Judgment affirmed, without costs, in a memorandum.