
201 Cal.App.3d 1346 (1988)
248 Cal. Rptr. 50
THE PEOPLE, Petitioner,
v.
THE SUPERIOR COURT OF THE CITY AND COUNTY OF SAN FRANCISCO, Respondent; MICHAEL AQUINO et al., Real Parties in Interest.
Docket No. A041664.
Court of Appeals of California, First District, Division Three.
June 9, 1988.
*1348 COUNSEL
Arlo Smith, District Attorney, and Hugh A. Donohoe, Assistant District Attorney, for Petitioner.
No appearance for Respondent.
Pillsbury, Madison & Sutro, Bernard Zimmerman and Shawn Hanson for Real Parties in Interest.
OPINION
WHITE, P.J.
The People of the State of California, represented by the San Francisco District Attorney, challenge a magistrate's ruling denying them party status on a motion to return property seized during execution of a search warrant. They contend that the superior court erred in failing to issue a writ to compel the magistrate to grant them party status. We conclude that under the circumstances of this case, the magistrate exceeded his jurisdiction and the superior court erred. We direct the superior court to issue writ of mandate (Code Civ. Proc., §§ 904.1, subd. (a)(4), 1086).
The San Francisco District Attorney's office has been involved in the ongoing investigation of real party in interest, Lieutenant Colonel Michael Aquino. Assistant District Attorney Michael Williams reviewed police reports and evidence, assisted in the preparation of the affidavit in support of *1349 a search warrant, reviewed the final form of the warrant before it was presented to a judge, reviewed all property seized pursuant to the warrant, and arranged with defense counsel for the return of many of the items seized. However, to date no criminal charges have been brought against Colonel Aquino.
Some three months after execution of the search warrant, Lieutenant Colonel and Mrs. Aquino noticed a motion to restore the property (Pen. Code, §§ 1539-1540). The notice, filed in the municipal court, entitled "In re 36 Video Tapes, etc., seized from Lieutenant Colonel and Mrs. Michael Aquino," was directed to the San Francisco Police Department, and was served on the legal department of the police department but not upon the district attorney. The motion was heard by a municipal court judge, apparently sitting as a magistrate as suggested by Penal Code section 1540.
On the date of the hearing, having learned of the matter by chance, Assistant District Attorney George Butterworth appeared and asked the magistrate to grant his office the status of representative for a party to the proceedings. The magistrate denied the request, permitting Mr. Butterworth to argue the motion in an "advisory capacity," but not to question witnesses. Not satisfied with this result, petitioner sought a writ of mandate or prohibition and a stay from the superior court. That court issued a stay of the proceedings in the municipal court and an alternative writ of mandate. After hearing, the court denied the peremptory writ of mandate. This petition followed. We stayed further proceedings in the municipal court in order to consider the legal issues raised.
(1a) Petitioner contends that the magistrate erred in preventing the district attorney from performing its legal duties in conducting criminal proceedings on behalf of the People of the State of California. We agree. In criminal proceedings, "[t]he style of all process shall be `The People of the State of California,' and all prosecutions shall be conducted in their name and by their authority." (Gov. Code, § 100, subd. (b); see also Pen. Code, § 684.) "The district attorney is the public prosecutor, except as otherwise provided by law. The public prosecutor shall attend the courts, and within his or her discretion shall initiate and conduct on behalf of the people all prosecutions for public offenses." (Gov. Code, § 26500.)
Real parties in interest[1] correctly observe that no criminal charges have been brought against them. Thus, no criminal proceedings are pending against them. (2a) But "[i]nvestigation and the gathering of evidence *1350 relating to criminal offenses is a responsibility which is inseparable from the district attorney's prosecutorial function. That the district attorney is charged with the duty of investigating as well as prosecuting criminal activity has been recognized by an unbroken line of California cases." (Hicks v. Board of Supervisors (1977) 69 Cal. App.3d 228, 241 [138 Cal. Rptr. 101].) (3a), (2b) It follows that the requirement that the public prosecutor shall "attend the courts" (Gov. Code, § 26500) applies not only to post-complaint proceedings, but also to precomplaint proceedings which call into question the district attorney's investigation of suspected criminal activity. (3b) Precomplaint proceedings brought under Penal Code sections 1539 and 1540 are such proceedings when, as in this case, the district attorney has been involved in preparation of the affidavit and in the evaluation of the evidence seized.
(1b) We conclude also that the requirement that the district attorney "attend the courts" and conduct the prosecutions requires more than that he appear as an advisor to the court and argue points of law in a proceeding such as this. We read Government Code section 26500 to make the People of the State of California a party and to authorize the district attorney to represent them in these proceedings.
(4a) Real parties in interest question the right of the People to seek a writ under these circumstances. (5) They cite the correct legal principle: "If the prosecution has not been granted by statute a right to appeal, review of any alleged error may be sought by a petition for writ of mandate only when a trial court has acted in excess of its jurisdiction and the need for such review outweighs the risk of harassment of the accused. [Citations.]" (People v. Superior Court (Stanley) (1979) 24 Cal.3d 622, 625-626 [156 Cal. Rptr. 626, 596 P.2d 691], fn. omitted, stating principles derived from People v. Superior Court (Howard) (1968) 69 Cal.2d 491, 497-500 [72 Cal. Rptr. 330, 446 P.2d 138]; see also People v. Municipal Court (Kong) (1981) 122 Cal. App.3d 176 [175 Cal. Rptr. 861].) (4b) The superior court applied this principle and concluded that a writ did not lie because the magistrate merely abused his discretion but did not lack jurisdiction in the matter. We disagree; the magistrate lacked jurisdiction.
(6) Early in the proceedings Mr. Butterworth advised the magistrate that Assistant District Attorney Williams was involved in preparation of the warrant. Although at that point the magistrate considered whether Mr. Williams might be needed as a witness, he ultimately concluded that the People should not be accorded party status. We conclude that the magistrate lost jurisdiction over the subject matter of the hearing when he learned of the district attorney's role in investigating the matter and did not allow *1351 the People party status.[2] As explained above, the district attorney's involvement in the criminal investigation made the People a required party to proceedings questioning that investigation.
(4c) We conclude that the superior court committed legal error in failing to issue a writ compelling the magistrate to accord party status to the People. We issue writ of mandate to compel the superior court to grant petitioner's application for a peremptory writ (Code Civ. Proc., § 904.1, subd. (a)(4)). Having provided notice to real parties in interest and having received a brief in opposition, we issue a peremptory writ in the first instance. (Code Civ. Proc., § 1088; Palma v. U.S. Industrial Fasteners, Inc. (1984) 36 Cal.3d 171, 177-80 [203 Cal. Rptr. 626, 681 P.2d 893].)
Let a peremptory writ of mandate issue, directing the San Francisco County Superior Court to issue writ of mandate compelling the magistrate to grant party status to the People of the State of California. This court's stay of proceedings on the motion to restore property will dissolve upon finality of this opinion.
Merrill, J., and Strankman, J., concurred.
NOTES
[1]  Petitioner has designated the municipal court and the police department as additional real parties in interest. However, for convenience in the body of this opinion, we use the term "real parties in interest" to refer only to Lieutenant Colonel and Mrs. Aquino.
[2]  Because we find the ruling of the magistrate to be in excess of jurisdiction, we need not consider whether People v. Superior Court (Chico etc. Health Center) (1986) 187 Cal. App.3d 648 [232 Cal. Rptr. 165], is correctly reasoned. The Chico etc. Health Center court concluded that the principles stated in Howard, supra, 69 Cal.2d 491, do not apply to writs challenging actions by magistrates, as distinguished from writs challenging rulings by courts. (Id., at pp. 654-655.) We do note, however, that the conclusion in Chico, etc. Health Center is at odds with our results in People v. Municipal Court (Kong), supra, 122 Cal. App.3d 176, where we applied the Howard principles to uphold a superior court's refusal to issue writ of mandate against a magistrate's ruling.
