
110 Cal.App.3d 174 (1980)
167 Cal. Rptr. 749
CLAYTON JACKSON, Petitioner,
v.
THE SUPERIOR COURT OF THE CITY AND COUNTY OF SAN FRANCISCO, Respondent; THE PEOPLE, Real Party in Interest.
Docket No. 49571.
Court of Appeals of California, First District, Division Two.
September 12, 1980.
*175 COUNSEL
Jack Morgan for Petitioner.
No appearance for Respondent.
George Deukmejian, Attorney General, Robert H. Philibosian, Chief Assistant Attorney General, Edward P. O'Brien, Assistant Attorney General, Robert R. Granucci and Herbert F. Wilkinson, Deputy Attorneys General, for Real Party in Interest.
*176 OPINION
SMITH, J.
Petitioner, charged by information with violation of section 487, subdivision 2, of the Penal Code (theft from the person),[1] seeks relief by extraordinary writ to compel respondent Superior Court of the City and County of San Francisco to grant his motion to set aside the information. Petitioner contends that his commitment is illegal because the magistrate refused to exercise his discretion to reduce the offense to a misdemeanor unless petitioner entered a plea of guilty.
Petitioner was charged initially by complaint with a violation of section 487 which provides: "Grand theft is theft committed in any of the following cases ... 2. When the property is taken from the person of another." At the preliminary hearing it was shown that petitioner took a red cigarette case containing two $1 bills from the person of a police decoy who was sitting in a doorway posing as an old and injured woman. Grand theft is punishable by imprisonment in the county jail for not more than one year or in the state prison (§ 489); petitioner sought to have the magistrate exercise his discretion under section 17, subdivision (b) (5) to declare the offense a misdemeanor.
Section 17, subdivision (b) provides: "When a crime is punishable, in the discretion of the court, by imprisonment in the state prison or by fine or imprisonment in the county jail, it is a misdemeanor for all purposes under the following circumstances: ... (5) When, at or before the preliminary examination or prior to filing an order pursuant to Section 872, the magistrate determines that the offense is a misdemeanor, in which event the case shall proceed as if the defendant had been arraigned on a misdemeanor complaint."
(1) In determining whether a defendant should be held to answer on a felony or a misdemeanor, "a committing magistrate exercises a judicial power which must be based upon an examination of the circumstances of the particular case before him." (Esteybar v. Municipal Court (1971) 5 Cal.3d 119, 125 [95 Cal. Rptr. 524, 485 P.2d 1140].) Esteybar held that a defendant is entitled to have an independent determination of whether he should be held to answer on a felony or a misdemeanor, and that the exercise of judicial discretion could not be conditioned upon the consent of the district attorney. We hold that the *177 magistrate may not condition the exercise of his judicial discretion to reduce the offense to a misdemeanor upon the entry of a plea of guilty by the defendant (see In re Lewallen (1979) 23 Cal.3d 274, 278-279 [152 Cal. Rptr. 528, 590 P.2d 383]).[2]
(2) It is settled that denial of a substantial right at the preliminary examination renders the ensuing commitment illegal and entitles a defendant to dismissal of the information on timely motion. (People v. Pompa-Ortiz (1980) 27 Cal.3d 519, 523 [165 Cal. Rptr. 851, 612 P.2d 941].) The Attorney General argues, however, that petitioner is not entitled to relief under section 995 because section 995 applies only to violations of sections contained in title 3, chapter 7 (§§ 858-883).
It is true that classically a section 995 motion is made when a preliminary examination has allegedly not been held in accord with the "procedures established by law" and the "substantial rights" guaranteed to a defendant under title 3, chapter 7. (People v. Elliot (1960) 54 Cal.2d 498, 503 [6 Cal. Rptr. 753, 354 P.2d 225] (overruled on another point; see Pompa-Ortiz, supra, 27 Cal.3d 519, 529).) The defendant's right to move the magistrate for section 17, subdivision (b) (5), relief is not a right enumerated under that chapter. However, when a magistrate exercises his independent discretion, under section 17, subdivision (b) (5), thereby deciding whether or not a defendant should be held to a felony or misdemeanor, there is a substantial right at stake. There must be a method, other than by writ, to challenge a misapplication of section 17, subdivision (b) (5). A section 995 motion provides such a quick and efficient remedy. (3) We hold that a defendant's right to an independent determination of whether he should be held to answer on a felony or a misdemeanor cannot be given meaningful effect unless the defendant may raise the magistrate's failure to exercise his judicial discretion through a pretrial motion to dismiss (see People v. Backus (1979) 23 Cal.3d 360, 381 [152 Cal. Rptr. 710, 590 P.2d 837]).
*178 We conclude that under the circumstances shown petitioner had not been legally committed by a magistrate and that petitioner was entitled to relief under section 995.
Petitioner had prayed for relief by mandate, and we issued an alternative writ of mandate. Prohibition is the proper remedy. The alternative writ of mandate is therefore discharged, and a peremptory writ of prohibition shall issue to restrain respondent superior court from taking any further action in the proceedings against petitioner, other than to grant the motion and proceed according to law. (§§ 995, 997.)
Rouse, Acting P.J., and Miller, J., concurred.
NOTES
[1]  All subsequent code references shall be to the Penal Code, unless otherwise indicated.
[2]  That the magistrate conditioned the exercise of his discretion to reduce the offense to a misdemeanor upon the entry of plea of guilty is supported by relevant portions of the preliminary transcript, as follows: "MR. MORGAN [Counsel for petitioner]: Submitted, your Honor. I would ask that the Court exercise its discretion under Escobar versus Municipal Court and reduce the matter to a misdemeanor.

"THE COURT: I am more than willing to on a plea, but not to send the matter down 
"MR. MORGAN: Is it my understanding that the Court is willing to do it on the basis of a plea of guilty, but not willing to do it on just exercising its discretion?
"THE COURT: That is correct.
"MR. MORGAN: Thank you. Then we will submit the matter."
