
66 Cal.2d 867 (1967)
FRED JAMES JENNINGS, Petitioner,
v.
THE SUPERIOR COURT OF CONTRA COSTA COUNTY, Respondent; THE PEOPLE, Real Party in Interest.
S. F. No. 22502. 
Supreme Court of California. In Bank.  
June 16, 1967.
 David N. Bortin, under appointment by the Supreme Court, for Petitioner.
 Thomas C. Lynch, Attorney General, Albert W. Harris, Jr., Assistant Attorney General, Robert R. Granucci and Robert S. Shuken, Deputy Attorneys General, for Respondent and for Real Party in Interest.
 MOSK, J.
 The sole question presented in this proceeding for a writ of prohibition is the scope and enforceability of a *871 defendant's right to present an affirmative defense at his preliminary hearing if he so chooses. We have concluded that this right is guaranteed by constitution and by statute and that its timely assertion in the case at bar requires issuance of a peremptory writ.
 Petitioner was charged by complaint with illegal possession of narcotics (Health & Saf. Code,  11500) and narcotics paraphernalia (Health & Saf. Code,  11555). Other than a criminalist who identified the narcotic character of the substance recovered, the sole witnesses at the preliminary hearing were the two arresting officers, Johnson and Bedsworth. Both testified on direct examination that at 12:30 a.m. on October 22, 1966, they were in the vicinity of the Royal Palms Motel in Concord when they observed a Chevrolet station wagon pull up and park behind the motel. A woman got out of the car and ran towards the front of the building. "It being unusual," the officers testified, they approached and observed petitioner get out and stand next to the car. When petitioner saw the officers he began to run. He threw a pink object over a nearby fence, and the officers heard a metallic sound when the object struck the concrete on the other side.petitioner then stopped and waited for the officers. Officer Johnson detained him while Officer Bedsworth retrieved the object. It was found to be a narcotics injection kit, and petitioner was formally placed under arrest. Officer Johnson then asked him who the woman was, and he said her name was Sherrie Kittelson.
 Petitioner concedes that the foregoing evidence, taken alone, would be sufficient to constitute probable cause to hold him to answer to the charges in the complaint. At the outset of the hearing, however, and before any witness had testified, counsel for petitioner advised the court he had attempted to subpoena Miss Kittelson, but that the return had just been handed to him unserved. He further stated that the district attorney's office had informed him she was out on bail on a pending criminal charge and was due to appear in court on the following Monday (it was then Thursday morning), at which time presumably she could be served with a subpoena to appear at his preliminary hearing. He therefore moved for a continuance of the hearing for four days.
 In response to the court's request for an offer of proof of the necessity for such a continuance, petitioner's counsel explained there was "a very serious question" as to whether the contraband in issue had been in Miss Kittelson's possession *872 or his client's. He stated, "my understanding of the matter is that this woman called the defendant and asked him to come to pick her up at a certain place and he responded to her request and at that particular point she left the car and at that point the officers descended on the car and found the merchandise in question. I think she's vital to this particular case." The prosecution objected to the continuance, arguing that the evidence would show petitioner had the narcotics kit in his hand and threw it away, and that the facts which he was offering to prove were simply "a matter of defense." The court stated that the prosecution's evidence "would be sufficient for this preliminary stage notwithstanding any statements that might be made by Miss Kittelson," but nevertheless took the motion under submission.
 The issue quickly came up again on petitioner's cross-examination of the arresting officers. Officer Johnson testified that petitioner's car made a loud exhaust noise and it was that noise which first attracted his attention to the vehicle. He admitted, however, that he "knew who it was" when Miss Kittelson alighted from petitioner's car and ran to the front of the motel, and knew she was out on bail at the time.petitioner's counsel then asked whether she had been in contact with the Concord Police Department earlier that day or week; the prosecution objected on the ground of relevancy, and again an offer of proof was requested. Counsel stated that the officer's testimony on direct had been an effort to lead the court to believe that reasonable cause to arrest was based solely on the events observed at the scene, i.e., the assertedly defective exhaust and the flight of the apparently unknown woman; rather, counsel advised the court, "I believe that I can develop on cross-examination that there was an entirely different reason for these law enforcement officers to be there and for this arrest to be made and that the lawfulness of the arrest is based, in fact, on a setup or an arrangement that was made in advance." The objection was nevertheless sustained.
 On further cross-examination Officer Johnson admitted he and his partner had been sitting at that location for 20 to 30 minutes before petitioner and Miss Kittelson arrived; counsel for petitioner then asked, "Was this in response to some information you had received," and the prosecution again objected on the ground of relevancy. Counsel explained he was trying to establish that "in point of fact ... this was an arrest based on information given to the police in an effort to *873 entice this defendant to a particular spot, where he would, in fact, be arrested on the basis of possession of material which they knew would then be in the car, and I think it's extremely vital to the basic defense of this case, which is, in fact, that the defendant was setup or in the vernacular framed. ..."
 The court made it clear that although it disbelieved the officer's story of a chance encounter with petitioner and Miss Kittelson, it was of the opinion that the only issue at a preliminary hearing was whether there was probable cause to hold the accused to answer to the charges filed, and that the evidence sought to be introduced by petitioner was simply not relevant to that issue. Thus the court said, "I'm not so naive that I don't think we have police operating with information that they receive from other persons. Of course, I don't believe that this is an isolated incident whereby [the police] are parked on the street corner of Clayton Way and Queen's Road without some purpose in mind before [petitioner and Miss Kittelson] drove up in this vehicle and then that their attention was attracted by a noisy muffler and they went out of the vehicle and observed this man run and throw something over the fence but I feel that what led up to this action is hardly material to this matter at this stage of the proceeding. Now, whether the man was, in fact, framed, or whether they took advantage of him or whatever else may have happened preceding this, I don't see how that would affect this preliminary at this stage." (Italics added.)
 In response to the court's emphasizing the fact that petitioner was seen to run with the contraband in his hand and throw it over the wall, counsel pointed out that "if in point of fact, the defendant realizes from the circumstances that he was being framed and attempts to get out of the frame, this is quite a different situation [than] where a defendant was in fact guilty and was in fact fleeing from or taking evasive action from a consciousness of guilt. ..." Nevertheless, the court ruled that "maybe these things are all germane to a defense at the time of trial but at this time I don't see where they would be relevant nor come under the scope of a preliminary examination so I'm going to limit you as to what occurred here and not as to any prior communications or reasons the police may have had for being there."
 The same rule was enforced throughout counsel's cross-examination of Officer Bedsworth. At the conclusion of the People's evidence counsel again expressed his desire to put *874 Miss Kittelson on the stand, but for the foregoing reasons the court also denied his motion for a continuance.
 Petitioner was held to answer. He moved to set aside the information under Penal Code section 995 on the ground that he had not been legally committed; the motion was denied, and petitioner instituted the present proceedings for writ of prohibition.
 [1] Section 995 provides in relevant part that upon motion the information "must" be set aside by the court in which the defendant is arraigned if it appears "That before the filing thereof the defendant had not been legally committed by a magistrate." As we explained in People v. Elliot (1960) 54 Cal.2d 498, 502-503 [6 Cal.Rptr. 753, 354 P.2d 225], " 'The phrase "legally committed," ... refers to the examination of the case and the holding of the defendant to answer, as prescribed by title 3, chapter 7, of the Penal Code.' (Ex parte Baker, 88 Cal. 84, 85 [25 P. 966].) [2] An information, of course, will not be set aside merely because there has been some irregularity or minor error in procedure in the preliminary examination. (People v. Rodrigo, 69 Cal. 601 [11 P. 481].) But where it appears that, during the course of the preliminary examination, the defendant has been denied a substantial right, the commitment is unlawful within the meaning of section 995, and it must be set aside upon timely motion. [Citations.]" (Italics added.)
 Applying these rules in a variety of contexts, the courts have held that an accused was not "legally committed" when he was denied the right to the assistance of counsel at the preliminary hearing (People v. Napthaly (1895) 105 Cal. 641, 644-645 [39 P. 29]; McCarthy v. Superior Court (1958) 162 Cal.App.2d 755, 758-759 [328 P.2d 819]; People v. Williams (1954) 124 Cal.App.2d 32, 38 [268 P.2d 156]; Pen. Code,  866.5), when he was not advised by the magistrate, as required by section 859, of his right to such counsel (People v. Miller (1932) 123 Cal.App. 499, 501-502 [11 P.2d 884]; People v. Salas (1926) 80 Cal.App. 318 [250 P. 526]), when the magistrate both listened to argument by the prosecution and ruled on the motion to dismiss the information without notifying the defendant's counsel (People v. Hellum (1962) 205 Cal.App.2d 150, 153-154 [22 Cal.Rptr. 724]), when the magistrate denied the defendant a reasonable continuance to permit him to send for counsel, as required by section 860 (People v. Phillips (1964) 229 Cal.App.2d 496, 501-502 [40 Cal.Rptr. 403]) or granted the prosecution's unsupported motion for a *875 one-day continuance to secure a witness, in violation of the command of section 861 to complete the hearing "at one session" (People v. Bucher (1959) 175 Cal.App.2d 343 [346 P.2d 202]), or when the magistrate allowed an unauthorized person to remain in the courtroom during the hearing, after the defendant had moved to exclude all such persons under section 868 (People v. Elliot (1960) supra, 54 Cal.2d 498). It will be observed, however, that none of the foregoing decisions dealt with erroneous rulings of the magistrate on the admissibility of evidence; as will appear, under the decided cases a more selective test is applied to that type of error.
 [3a, 4a] Petitioner asserts he has been denied the benefit of Penal Code section 865, which provides that at preliminary hearings "The witnesses must be examined in the presence of the defendant, and may be cross-examined in his behalf," and section 866, which provides that "When the examination of the witnesses on the part of the people is closed, any witnesses the defendant may produce must be sworn and examined." [5] Doubtless these statutes are declaratory of fundamental procedural rights; they are derived from our earliest criminal legislation (Stats. 1851, ch. 29,  153, 159) and have remained unchanged since the codification of the Penal Code in 1872. They were among the statutes relied on by the United States Supreme Court in the landmark decision of Hurtado v. California (1884) 110 U.S. 516, 538 [28 L.Ed. 232, 239, 4 S.Ct. 111, 292], holding that the proceeding by preliminary examination, commitment, and information, "carefully considers and guards the substantial interest of the prisoner" and thus constitutes due process of law. The right to present and cross-examine witnesses is, of course, as essential today as it was in 1884. (See, e.g., Specht v. Patterson (1967) 386 U.S. 605 [18 L.Ed.2d 326, 87 S.Ct. 1209]; Pointer v. Texas (1965) 380 U.S. 400 [13 L.Ed.2d 923, 85 S.Ct. 1065]; Douglas v. Alabama (1965) 380 U.S. 415 [13 L.Ed.2d 934, 85 S.Ct. 1074].)
 [3b, 4b] The People's principal position is that petitioner was not in fact denied these rights; rather, it is asserted, the magistrate simply "exercised his discretion" to deny a continuance and limit the scope of cross-examination. On the record before us, the contention is not persuasive.
 [6] "While the determination of whether in any given case a continuance should be granted 'normally rests in the discretion of the trial court' (People v. Buckowski (1951) 37 Cal.2d 629, 631 [233 P.2d 912]), that discretion may not be *876 exercised in such a manner as to deprive the defendant of a reasonable opportunity to prepare his defense. [7] 'That counsel for a defendant has a right to reasonable opportunity to prepare for a trial is as fundamental as is the right to counsel.' (People v. Sarazzawski (1945) 27 Cal.2d 7, 17 [161 P.2d 934]; accord, Cooper v. Superior Court (1961) 55 Cal.2d 291, 302 [10 Cal.Rptr. 842, 359 P.2d 274].) It is also as fundamental as the defendant's right to be advised of the charges against him, for the latter right is illusory if he then is denied sufficient time to prepare to meet such charges. (See In re Hess (1955) 45 Cal.2d 171, 175 [288 P.2d 5], and cases cited.)" (People v. Murphy (1963) 59 Cal.2d 818, 825 [31 Cal.Rptr. 306, 382 P.2d 346].)
 [8a] The absence of a material witness for the defense, under appropriate conditions, has long been recognized as a ground for continuance. (See, e.g., People v. Dodge (1865) 28 Cal. 445.) [3c] Here the People concede in their return "the brevity of the requested continuance, the good faith efforts by defense to find the witness and lack of inconvenience to the prosecution," but assert that Miss Kittelson was not a "vital" witness. [8b] In this respect, however, the law requires only that the proposed testimony be material and cannot be elicited from another source. Both of the latter elements were present in this case. [9] The gravamen of the offenses charged is knowing possession of the contraband. (See People v. Leal (1966) 64 Cal.2d 504 [50 Cal.Rptr. 777, 413 P.2d 665]; People v. Redrick (1961) 55 Cal.2d 282, 285 [10 Cal.Rptr. 823, 359 P.2d 255], and cases cited.) [3d] The narcotics kit came from a car in which only petitioner and Miss Kittelson were riding, and either could have been in possession thereof. The woman was known to the police, and was then out on bail on a pending criminal charge. Petitioner's counsel offered to prove that it was Miss Kittelson who initiated and arranged the meeting with petitioner in his car, who directed him to the location where the police were waiting, and whose flight from the vehicle was the signal to the officers to pounce on petitioner. Such evidence would not have been cumulative or obtainable from another source, and would unquestionably have been material to petitioner's defense of entrapment.  [fn. 1] It follows that the court erred in denying petitioner's motion for a continuance. *877
 Similar considerations govern the issue of petitioner's right to cross- examine the arresting officers. [10] "While the trial judge has broad discretion to control the ultimate scope of cross-examination designed to test the credibility or recollection of a witness (People v. Burton (1961) 55 Cal.2d 328, 343 [11 Cal.Rptr. 65, 359 P.2d 433]), yet wherever possible that examination 'should be given wide latitude, particularly in cases involving "a witness against a defendant in a criminal prosecution" ' (People v. Watson (1956) 46 Cal.2d 818, 827 [299 P.2d 243])." (People v. Murphy (1963) supra, 59 Cal.2d 818, 830-831.) [4c] Here, cross-examination was limited by the court to the events described by the officers on direct, and counsel was cut off each time he sought to inquire whether the officers had been in previous contact with Miss Kittelson and whether they had stationed themselves at that precise location by prearrangement with her. [11] But it is settled that even the cross-examination of a defendant who chooses to take the stand need not be "confined to a mere categorical review of the matters, dates or times mentioned in the direct examination. [Citations.] It may be directed to the eliciting of any matter which may tend to overcome or qualify the effect of the testimony given by him on his direct examination." (People v. Zerillo (1950) 36 Cal.2d 222, 228 [223 P.2d 223].) This rule applies a fortiori when the witness is not the defendant but his accuser.
 [4d] Petitioner's inquiry was intended to aid in establishing his defense, both by overcoming or qualifying the effect of the officers' testimony on direct examination and by eliciting additional evidence to complement the expected testimony of Miss Kittelson. It was obvious the officers had not told the whole story of that evening's events; indeed, even the magistrate remarked he was "not so naive" as to believe their implication that it all began as a chance encounter.  [fn. 2] These *878 were matters largely within the witnesses' own knowledge, and had not been covered by previous questioning. Petitioner should accordingly have been allowed to inquire into them on cross-examination, and the court erred in foreclosing him from doing so.
 It remains to determine the effect of these errors in the present context. [12] In Rogers v. Superior Court (1955) 46 Cal.2d 3, 6-7 [291 P.2d 929], we held that prohibition does not lie to review rulings of the magistrate on the admissibility of evidence at the preliminary hearing, unless the commitment is based entirely on incompetent evidence. We adhere to that rule, and we find in the cases of Priestly v. Superior Court (1958) 50 Cal.2d 812 [330 P.2d 39], and Mitchell v. Superior Court (1958) 50 Cal.2d 827 [330 P.2d 48], useful guidance in reconciling the declarations of principle of sections 865 and 866 with the practical limitations laid down in Rogers.
 In Priestly the sole incriminating evidence introduced at the preliminary hearing was obtained in the course of an arrest and search conducted without a warrant but on the basis of information received from confidential informants. The magistrate denied the defendant's motion to disclose the informants' identities or to strike the arresting officers' testimony. We granted a writ of prohibition, holding (at pp. 818-819) that "When the prosecution relies ... on communications from an informer to show reasonable cause and has itself elicited testimony as to those communications on direct examination, it is essential to a fair trial that the defendant have the right to cross-examine as to the source of those communications."  [fn. 3]
 In Mitchell, by contrast, the incriminating evidence was only partially the product of communications from confidential informants, and the defendants did not contend there was no competent evidence of reasonable cause. In those circumstances we reasoned (at pp. 829-830): "It is contended, however, that denial of the right of cross-examination at the preliminary hearing is not only a ruling on the admissibility of evidence but the denial of a constitutional right. It is unnecessary *879 to resolve this contention, for there was not such an interference with the right of cross-examination in this case as to justify a writ of prohibition. It does not appear that disclosure of the names of the informers was demanded to enable defendants to discredit the prosecution's evidence at the preliminary hearing or that they wished to use the informers as witnesses at that hearing." Indeed, the defendants admittedly did not intend to present an affirmative defense at the preliminary hearing, and desired the names of the informants solely as an aid in preparing for the ensuing trial. [13a] We concluded that the defendants were not deprived of any substantial right at the hearing, and accordingly denied the application for writ of prohibition.  [fn. 4] [See fn. 4.]
 The lesson of these cases, insofar as here relevant, is clear. [14] As summarized by Justice Carter in his concurring opinion in Priestly (50 Cal.2d at pp. 822-823), "Not [in] every instance in which a cross-examiner's question is disallowed will defendant's right to a fair hearing be abridged, since the matter may be too unimportant [citation], or there may be no prejudice [citation], or the question may involve issues which can be brought up at a more appropriate time [citation]. [13b] However, where the subject of cross-examination concerns the matter at issue there can be no doubt that the refusal to permit such question results in a denial of a fair hearing. [Citations.]" The case at bar falls into the latter category. [15a] Here, in contrast to Mitchell, petitioner did intend to present an affirmative defense at the preliminary hearing; he did desire to cross-examine on the excluded subjects for the purpose of discrediting the prosecution's evidence and developing his defense at that hearing, and he did intend to call Miss Kittelson as a witness on these subjects if he could obtain a continuance. It follows that on the facts of this case the refusal to grant a continuance and the restriction on cross- examination amounted to a denial of *880 petitioner's "substantial rights" in the preliminary hearing proceedings, and the resulting illegal commitment may be reached by way of prohibition.
 Finally, the People urge that even if the magistrate erred in denying a continuance and limiting cross-examination, the errors were not prejudicial because "The evidence of petitioner's conduct would still be sufficient to hold him over for trial." In this, the People share a misconception of the trial court which pervaded the entire proceedings below, i.e., that as long as the prosecution's evidence showed probable cause to hold petitioner to answer it was irrelevant at that stage "whether the man was, in fact, framed. ..." If this view were correct, of course, any cross-examination or testimony on behalf of the defendant would become superfluous. To accept the People's argument would be in effect to erase sections 865 and 866 from the books and reduce the preliminary hearing to an ex parte proceeding at which the defendant's presence would be a meaningless gesture. [16] In People v. Elliot (1960) supra, 54 Cal.2d 498, 504, we reiterated, "The preliminary examination is not merely a pretrial hearing. 'The purpose of the preliminary hearing is to weed out groundless or unsupported charges of grave offenses, and to relieve the accused of the degradation and expense of a criminal trial. Many an unjustifiable prosecution is stopped at that point, where the lack of probable cause is clearly disclosed.' (Jaffe v. Stone, 18 Cal.2d 146, 150 [114 P.2d 335, 135 A.L.R. 775].)" Accord, Mitchell v. Superior Court (1958) supra, 50 Cal.2d 827, 829.) To effectuate this constitutional and statutory purpose the defendant must be permitted, if he chooses, to elicit testimony or introduce evidence tending to overcome the prosecution's case or establish an affirmative defense.
 We recognize that many defendants do not offer such evidence at the preliminary hearing, preferring to await the actual trial before disclosing their defensive strategy. But the infrequency with which the procedure is invoked does not make it any the less lawful and proper. We further recognize that when a defendant fails to challenge, by motion to dismiss and writ of prohibition, errors of the magistrate in ruling on the admissibility of evidence (as distinguished from such fundamental deprivations as denial of counsel or of an unbiased jury), he will ordinarily receive a fair trial if correct rulings are thereafter made at the trial on the merits; in that event, on an appeal from a judgment of conviction the errors may be found to have been cured in the subsequent proceedings *881 (see, e.g., People v. Neal (1942) 53 Cal.App.2d 379, 383 [127 P.2d 996]). [15b] But when, as here, the defendant makes a timely motion to dismiss and brings the matter before us on a petition for writ of prohibition, the conditions for granting relief are fulfilled and he is entitled to a peremptory writ without further showing.
 Let the peremptory writ of prohibition issue as prayed.
 Traynor, C. J., Peters, J., Tobriner, J., Burke, J., and Sullivan, J., concurred.
 McCOMB, J.
 I dissent: I would deny the writ.
NOTES
[fn. 1]  1. Indeed, the People recognize in their return that Miss Kittelson's testimony "would possibly show collaboration with the police and might show that the narcotics paraphernalia was hers." The materiality of her testimony, moreover, has impliedly been conceded by the People in a joint stipulation of the parties, appended by petitioner to his petition for hearing in this court, reciting that "the People intend to call Sherrie Kittelson as a witness" in the trial of this case.
[fn. 2]  2. In this connection we may take notice of petitioner's allegations that pursuant to pretrial discovery the prosecution has furnished him with a tape-recorded statement of Miss Kittelson in which she explains that she was given $20 by Officers Bedsworth and Johnson "To score some heroin," and that "we [Miss Kittelson and petitioner] headed back towards Concord. I stopped to call the Concord Police Department, told them that we were on our way here to Concord, we went to the Royal Palms Motel and I got out of the car and Fred Jennings was arrested."petitioner further informs us that "The prosecution advises that the testimony of the police officers will now be consistent with this statement, indicating that after such preparation, they were specifically waiting for the witness and the defendant to appear at the time and place of arrest."
[fn. 3]  3. This holding was correct under the statutes then in force, and is not vitiated by Martin v. Superior Court (1967) ante, p. 257 [57 Cal.Rptr. 351, 424 P.2d 935], in which we upheld the constitutionality of subsequent legislation designed to modify the Priestly rule (Code Civ. Proc.,  1881.1).
[fn. 4]  4. Similarly distinguishable are People v. Malloy (1962) 199 Cal.App.2d 219, 238 [18 Cal.Rptr. 545], in which the curtailed cross-examination would have been unduly repetitious of previous questioning, and People v. Wilson (1960) 183 Cal.App.2d 149, 153 [6 Cal.Rptr. 872], in which the excluded testimony was directed to impeachment rather than to establishing an affirmative defense. Wilson, however, is cited approvingly in Malloy for the proposition that "If the right of cross-examination is not generally denied, a showing of probable cause will support the legality of the commitment. Under such circumstances, error in excluding testimony on cross-examination is not grounds for dismissal under section 995." (199 Cal.App.2d at p. 238.) Such language should hereafter be read in the light of the present opinion.
