
604 P.2d 809 (1980)
SHERIFF OF WASHOE COUNTY, Nevada, Appellant,
v.
Thomas Gene VASILE, Respondent.
No. 12195.
Supreme Court of Nevada.
January 3, 1980.
Richard H. Bryan, Atty. Gen., Carson City, Calvin R.X. Dunlap, Dist. Atty. and R. Craig Lusiani, Deputy Dist. Atty., Washoe County, Reno, for appellant.
C. Frederick Pinkerton, Reno, for respondent.

OPINION
PER CURIAM:
Thomas Gene Vasile was charged with a violation of NRS 453.321, sale of a controlled substance. A preliminary examination was held in the justice's court, and Vasile was bond over to the district court. A timely petition for a pretrial writ of habeas corpus was granted by the district court. The state appeals from the subsequent dismissal of all charges. We affirm.
At the preliminary examination, Reno police officer, John Douglas testified that he was introduced to Vasile at a Reno hotel. Introduction was made by a person referred to by Officer Douglas as a "confidential informant."
*810 After the informant introduced Officer Douglas to Vasile, all three individuals walked together to the hotel parking lot. They got into an undercover police car, and a marijuana sale purportedly took place between Vasile and Officer Douglas. As Vasile got out of the car, Officer Douglas gave a prearranged signal to other officers in the area, and Vasile was apprehended.
During cross examination of Officer Douglas at the preliminary examination, defense counsel asked for the name of the person who introduced Officer Douglas to Vasile and who was seated in the car during the purported marijuana sale. The prosecutor's objection, based on the confidential informant privilege, NRS 49.335,[1] was sustained.
At the conclusion of the preliminary examination, defense counsel requested a dismissal of the charges due to the impairment of Vasile's right to confront and cross examine witnesses, especially with reference to the identity of the so-called confidential informant. The magistrate did not expressly rule on the request for a dismissal. Instead, the magistrate ordered Vasile to answer charges in the district court.
The state's privilege to refuse disclosure of the identity of an informant is not unlimited. Where there is a reasonable probability that the informant can give testimony necessary to a fair determination of the issue of guilt or innocence, the state's claim of the privilege may result in a dismissal. NRS 49.365.[2]
In addition, the accused at a preliminary examination has the right to cross examine witnesses against him and to introduce evidence in his own behalf. NRS 171.196(4). Denial of this right by the magistrate is error. See Routhier v. Sheriff, 93 Nev. 149, 560 P.2d 1371 (1977). Under such circumstances, a writ of habeas corpus is an appropriate remedy. See Routhier v. Sheriff, supra.
In Routhier v. Sheriff, supra, the magistrate required a prosecution witness to divulge the name of an informant who had set up and witnessed the transaction which led to criminal charges. The magistrate, however, refused to grant a continuance to permit Routhier to call and interrogate the witness. The refusal denied the accused his right to call and cross examine witnesses under NRS 171.196(4), and the district court's denial of Routhier's petition for a writ of habeas corpus was reversed.
In the present case the magistrate refused to require disclosure of any information as to the identity of the witness. The state contends, however, that the identity of the informant need not have been disclosed because he was not a percipient witness.[3] The identity of an informant need not be disclosed where he is not a material witness, because he can neither supply information constituting a defense nor rebut a necessary element of an offense. Twigg v. Sheriff, 95 Nev. 112, 590 P.2d 630 (1979); State v. Stiglitz, 94 Nev. 158, 576 P.2d 746 (1978).
In Routhier v. Sheriff, supra, the informant set up and witnessed the transaction which led to criminal charges. That was precisely the situation involved in the present case. The informant here was seated in the undercover police car with Officer Douglas and Vasile. He was apparently *811 the only independent witness who could hear and see the transaction in question. He was a material witness whose identity should have been disclosed. The magistrate's refusal to require disclosure or dismiss the charges was error. Thus, the district court correctly granted Vasile's habeas petition. NRS 171.196(4). See Routhier v. Sheriff, supra.
In light of our ruling, it is not necessary to decide other grounds for dismissal raised in the habeas petition.
Affirmed.
NOTES
[1]  NRS 49.335 provides:

"The state or a political subdivision thereof has a privilege to refuse to disclose the identity of a person who has furnished to a law enforcement officer information purporting to reveal the commission of a crime."
[2]  NRS 49.365 provides:

"If the state or a political subdivision elects not to disclose the identity of an informer and the circumstances indicate a reasonable probability that the informer can give testimony necessary to a fair determination of the issue of guilt or innocence, the judge shall on motion of the accused dismiss the proceedings, and he may do so on his own motion."
[3]  At the preliminary examination the prosecutor argued that the informer was not a percipient witness. Rather, he was "merely someone who was there at the time things went down." In opposition to the petition for a writ of habeas corpus the state argued in District Court that the informant "merely observed the transaction."
