
196 Cal.App.3d 809 (1987)
241 Cal. Rptr. 123
BILLY RAY WALDON, Petitioner,
v.
THE SUPERIOR COURT OF SAN DIEGO COUNTY, Respondent; THE PEOPLE, Real Party in Interest.
Docket No. D006915.
Court of Appeals of California, Fourth District, Division One.
October 20, 1987.
*811 COUNSEL
Geraldine S. Russell and Charles R. Khoury, Jr., for Petitioner.
Lloyd M. Harmon, Jr., County Counsel, Daniel J. Wallace, Chief Deputy County Counsel, and Barbara Baird, Deputy County Counsel, for Respondent.
Edwin L. Miller, Jr., District Attorney, Peter C. Lehman, Charles L. Patrick and D. Michael Ebert, Deputy District Attorneys, for Real Party in Interest.
OPINION
WORK, J.
Defendant Billy Ray Waldon seeks a writ of mandate after denial of a peremptory judicial challenge pursuant to Code of Civil Procedure section 170.6.[1] We hold a Penal Code section 1368 competency hearing is a separate proceeding from an underlying criminal action for purposes of exercising a section 170.6 challenge. Waldon was therefore entitled to exercise a peremptory challenge in his criminal proceedings despite his earlier exercising a peremptory challenge during competency proceedings. We further hold Waldon's peremptory challenge was timely filed after the denial of his challenge for cause. (§ 170.3.) Accordingly, we grant Waldon's petition, direct the superior court to grant his peremptory judicial challenge and vacate the stay.


*812 I
Waldon is charged with three counts of murder, five special circumstances and numerous other felony charges. During pretrial proceedings Waldon asked to represent himself in propria persona. At a hearing on that request a court-appointed psychiatrist expressed the opinion Waldon was not competent to stand trial.
The court suspended criminal proceedings to hold a competency hearing pursuant to Penal Code section 1368. Both the prosecution and Waldon exercised section 170.6 peremptory challenges to judges during the competency proceedings. Judge Levitt was then assigned to conduct the competency proceedings. On September 21, 1987, a verdict of competency to stand trial was rendered.
On September 24 Judge Richard Haden, Presiding Judge of the Superior Court Criminal Department, announced he intended to assign the criminal case for all purposes, including trial, to Judge Levitt. On September 29 Waldon filed a challenge for cause pursuant to section 170.3 against Judge Levitt in the presiding department. On September 30 Judge Haden assigned the case to Judge Levitt for all purposes including trial and transferred the challenge for cause to Judge Levitt. At the time of the assignment Waldon's counsel reserved the right to file a section 170.6 challenge in the event the challenge for cause was denied. That same day, Judge Levitt struck the challenge for cause as being insufficient on its face.
The next day Waldon petitioned for a writ of mandate from this court to compel Judge Levitt to set aside his order striking the challenge for cause. On Friday, October 2, this court notified Waldon the writ had been denied. Waldon immediately attempted to file a written section 170.6 challenge to Judge Levitt in the presiding department. Judge Haden refused to hear the matter, referring Waldon to Judge Levitt. Waldon then filed a peremptory challenge with Judge Levitt who denied it on the following grounds: 1) Waldon had already exhausted his peremptory challenge in the competency hearing and 2) the challenge was untimely. On Monday, October 5, Waldon obtained a stay of all pretrial and trial proceedings from this court.

II
(1) The first issue is whether Waldon's exercise of a peremptory challenge in the competency proceedings precludes him from exercising a second peremptory challenge in the criminal action. The parties have not cited nor have we found any authority directly on point. Section 170.6 permits a party to disqualify a judge deemed prejudiced by a simple charge supported *813 by a formal affidavit. However, section 170.6, subdivision (3) limits the exercise of that right as follows: "Under no circumstances shall a party or attorney be permitted to make more than one such motion in any one action or special proceeding...." Waldon is entitled to exercise a second peremptory challenge only if the Penal Code section 1368 proceedings were separate and distinct proceedings from the underlying criminal action.
Under Penal Code section 1368 a judge may order a hearing on a criminal defendant's present mental competency to stand trial. Penal Code section 1368, subdivision (c) provides that the judge shall suspend all proceedings in a criminal action until the question of the defendant's competence has been determined. A Penal Code section 1368 proceeding is given a separate style number and usually is assigned to another department or judge. Here criminal proceedings were suspended, mental health proceedings with a new style number were instituted and a new judge was assigned. The proceedings appear to be separate and distinct from the criminal action. Courts in other contexts have treated proceedings under Penal Code section 1368 as special proceedings. (People v. Hill (1967) 67 Cal.2d 105, 114 [60 Cal. Rptr. 234, 429 P.2d 586] (right to jury trial); People v. Fields (1965) 62 Cal.2d 538, 540 [42 Cal. Rptr. 833, 399 P.2d 369, 16 A.L.R.3d 708] (right to appeal); People v. Loomis (1938) 27 Cal. App.2d 236, 239-240 [80 P.2d 1012] (right to a jury).)
The prosecution, however, argues that the competency proceeding and the criminal proceeding constitute one action and, as such, only one peremptory challenge is allowed. The prosecution characterizes the competency hearing as a continuation of the criminal proceeding citing McClenny v. Superior Court (1964) 60 Cal.2d 677 [36 Cal. Rptr. 459, 388 P.2d 691].
The question in McClenny, supra, was whether a section 170.6 challenge was timely. The challenged judge had presided at a divorce proceeding and later issued two orders to show cause why the husband should not be held in contempt. The husband tried to disqualify the judge from hearing the contempt matter. The crucial question in McClenny, supra, was whether the contempt proceeding was a continuation of the original domestic relations action or whether it was a separate and independent proceeding. (Id. at p. 681.) The court held that a proceeding is a continuation of the original action out of which it arises if it involves substantially the same issues. (Id. at p. 684.) In McClenny, supra, the court noted the similarity and even identity of the issues raised in the contempt proceeding and the domestic relations proceeding in reaching its decision that the contempt proceeding was a continuation of the original action. (Id. at p. 684.)
McClenny, supra, does not support the prosecution's position that the competency hearing was a continuation of the criminal action. The issues in *814 the Penal Code section 1368 hearing were whether the defendant was able to comprehend the nature of the proceedings against him, whether he was able to comprehend his own status in reference to the proceedings, and whether he was able to assist in conducting his defense. (People v. Campbell (1976) 63 Cal. App.3d 599, 608 [133 Cal. Rptr. 815].) These are substantially different issues from those involved in the underlying criminal action. The Penal Code section 1368 proceeding can only be seen as separate and distinct from the criminal action from which it arose. The defendant was therefore entitled to exercise separate section 170.6 challenges in the competency hearing and the criminal action. The court below was in error when it denied the challenge because the defendant had exhausted his peremptory challenge in the competency hearing.

III
(2a) The second issue is whether the challenge was timely filed. Section 170.6 establishes various time limitations for peremptory challenges. (3) Generally, a motion is permitted any time before the beginning of a trial or a hearing. (Los Angeles County Dept. of Pub. Social Services v. Superior Court (1977) 69 Cal. App.3d 407, 412 [138 Cal. Rptr. 43].) There are two express statutory exceptions to the general rule set forth in section 170.6, subdivision (2), the 10-day-5-day rule and the master calendar rule. The 10-day-5-day rule provides:
"Where the judge, court commissioner, or referee assigned to or who is scheduled to try the cause or hear the matter is known at least 10 days before the date set for trial or hearing, the motion shall be made at least five days before that date." (Code Civ. Proc., § 170.6, subd. (2).) When a cause is assigned from a master calendar the challenge must be made to the judge supervising the master calendar at the time of assignment. (4) This court has held that an all-purpose assignment should be challenged at the earliest reasonable opportunity, namely, when the judge's identity becomes known. (Augustyn v. Superior Court (1986) 186 Cal. App.3d 1221, 1229 [231 Cal. Rptr. 298].)
(2b) Here Waldon executed a challenge for cause pursuant to section 170.3 even before the assignment to Judge Levitt was made. That challenge was pending at the time of the assignment. When the assignment was made, Waldon's counsel advised the court that should the challenge for cause be denied Waldon reserved the right to file a peremptory challenge pursuant to section 170.6. Upon being notified by this court that his petition for writ of mandate on the challenge for cause had been denied, Waldon immediately filed the peremptory challenge. The prosecution concedes and we agree that the challenge was timely filed. Pursuant to section 170.3, subdivision (d), *815 when Judge Levitt struck the challenge for cause as being facially insufficient, Waldon was entitled to seek review by writ of mandate. To require Waldon to file his peremptory challenge before the extraordinary review was completed would effectively deprive him of his right to pursue his challenge for cause.
(5) Nor does the fact Judge Levitt presided at the Penal Code section 1368 hearing make the challenge untimely. Under section 170.6, subdivision (2) the fact a judge has presided at a pretrial hearing does not preclude a later peremptory challenge unless the hearing involved a determination of contested fact issues. The Penal Code section 1368 hearing involved only a determination of the present mental capacity of the defendant to stand trial. No contested fact issues relating to the criminal proceeding were involved.
An alternative writ or order to show cause would add nothing to the presentation. A peremptory writ is proper. (Code Civ. Proc., § 1088; United Nuclear Corp. v. Superior Court (1980) 113 Cal. App.3d 359 [169 Cal. Rptr. 827]; Goodenough v. Superior Court (1971) 18 Cal. App.3d 692, 697 [96 Cal. Rptr. 165].)
Let a peremptory writ issue directing the superior court to grant Waldon's peremptory challenge pursuant to section 170.6. The stay of pretrial and trial proceedings issued by this court on October 5, 1987, is vacated.[2]
Kremer, P.J., and Todd, J., concurred.
A petition for a rehearing was denied November 10, 1987, and the petitions of respondent and real party in interest for review by the Supreme Court were denied January 28, 1988.
NOTES
[1]  All statutory references are to the Code of Civil Procedure unless otherwise specified.
[2]  We deny Waldon's additional request this court review its decision in D006718 relative to his being called as a witness at the Penal Code section 1368 hearing.
