OPINION
ALARID, Judge.Defendant appeals from his convictions for residential burglary and conspiracy to commit residential burglary. Defendant was charged with one count of residential burglary, in violation of NMSA 1978, Section 30-16-3(A) (Repl.Pamp.1984); one count of larceny over $2,500, in violation of NMSA 1978, Section 30-16-1 (Repl.Pamp. 1984); and one count of conspiracy to commit burglary, in violation of NMSA 1978, Section 30-28-2 (Repl.Pamp.1984). Count II was later changed to larceny over $100. Defendant was acquitted of count II, and convicted of counts I and III. Defendant filed a timely notice of appeal and docketing statement. The case was placed on the limited calendar.
Defendant raises only one issue on appeal: whether the trial court erred in ordering immunity from perjury for a co-defendant witness. We agree that the trial court’s order deprived defendant of a fair trial. We reverse the trial court, and remand for a new trial.
FACTS
The facts surrounding defendant’s indictment follow. We have drawn these facts from defendant’s docketing statement, and the state does not dispute them. On February 15, 1984, Charles Sanchez saw a vehicle pull up to his neighbor’s house at 2308 Headingly, N.W., in Albuquerque. One man got out, rang the doorbell, and then got back into the car. The car then turned and disappeared into a ditch bank. Sanchez called the owner of the house at 2308 Headingly, and the owner called the police.
The police responded to the call and went to the ditch bank near the house. They found defendant’s car parked along the ditch bank. He had a rag in his hands. Defendant claimed he was by himself. The police found wallets belonging to Paul Torres and Michael Barela in defendant’s car. Torres and Barela were seen running from the house at 2308 Headingly, and items from the house were found on Torres and Barela when they were apprehended.
Testimony and exhibits indicated that the burglary scene was not visible from the location of defendant’s vehicle. Defendant testified that he had given his co-defendants a ride that day and that he was waiting for them. He said he thought they were going to buy drugs.
The charges against the co-defendant Barela were dropped as part of a plea agreement. On May 3, 1985, defendant moved for an order compelling a statement from Barela because Barela refused to talk to defense counsel. On May 8, 1985, the assistant district attorney applied for a grant of immunity for Barela. Immunity from prosecution for peijury was granted on May 9, 1985. The order appears to read as follows:
ORDER OF IMMUNITY
This matter coming before the Court on the application of the State for a grant of immunity for Michael Barela, the Court being fully advised by the argument of counsel,
HEREBY FINDS:
That Michael Barela be granted immunity from prosecution [for] perjury as a result of his testimony in this cause based on Rule 58 Criminal Procedure and is and is [sic] therefore ordered to testify-
s/ Joseph Baca
District Judge
The order was also “read” to the jury at the request of defense counsel at trial. Judge Baca spoke as follows:
There has been an application for a grant of immunity by the District Attorney’s Office, and an order signed by this court:
This matter coming before the court on the application of the state for a grant of immunity for Michael Barela, the court, being fully advised by the arguments of counsel, hereby finds:
That Michael Barela be granted immunity from prosecution for his testimony, based on Rule 58 of the Criminal Rules of Procedure, and is hereby ordered to testify and any perjury as a result of his testimony ... that he would be granted immunity from prosecution for perjury.
The order granting immunity to Michael Barela forms the basis of this appeal.
Barela was given immunity because his counsel told the court he would refuse to answer questions unless he was given immunity. The court granted the immunity because Barela had given two prior statements, not under oath, which were inconsistent with each other. The court felt that any statement given at trial would be inconsistent with at least one of those, and expose Barela to a perjury charge. The court felt that immunity was proper under the circumstances, based on NMSA 1978, Crim.P.Rule 58 (Repl.Pamp.1985). Defense counsel did not object to the grant of immunity at trial.
DISCUSSION
Defendant argues that the witness, Bare-la, was granted use immunity, and that is not authorized under New Mexico law. Defendant argues that the grant of immunity was plain error because, interpreting it as he did, it gave the witness a license to lie on the stand. Under the theory advanced by defendant, the orders recited above gave the witness immunity from prosecution for perjury for any testimony that the witness might give at the trial of defendant. Defendant contends that the grant of immunity did away with the requirement that Barela testify truthfully at trial, and so defendant was denied his fifth amendment rights.
The state argues that the issue was not preserved for review because defendant failed to object at trial. The state also argues that defendant failed to show how he was prejudiced by the immunity order, and so defendant has no fundamental or plain error claim on appeal.
It is clear from the record that the trial court, through its immunity order, was encouraging Barela to testify. Also, under Crim.P. Rule 58, “the district court * * * may * * * issue a written order requiring [a] person to testify * * * notwithstanding his privilege against self-incrimination.” Crim.P.R. 58. Under Evidence Rule 412, “[e]vidence compelled under an order requiring testimony * * * may not be used against the person compelled to testify * * in any criminal case, except a prosecution for perjury committed in the course of the testimony* * *” NMSA 1978, Evid.R. 412 (Repl.Pamp.1983). These rules taken together create the witness immunity generally available in New Mexico. In addition, NMSA 1978, Section 31-6-15 (Repl.Pamp. 1984), codifies it.
Taken together, Crim.P. Rule 58, Evid. Rule 412, and Section 31-6-15 (formerly Section 31-3A-1 (Cum.Supp.1981)), give the trial court the authority to grant use immunity when it is applied for by the prosecutor. State v. Sanchez, 98 N.M. 428, 649 P.2d 496 (Ct.App.1982). Defendant argues that only transactional immunity is authorized under the rules. That is not correct.
In 1979, the Legislature passed a statute covering immunity. Section 31-3A-1, N.M.S.A. 1978 (1980 Supp.) [identical to present Section 31-6-15], provides only for use and derivative use immunity * Under Campos v. State, 91 N.M. 745, 580 P.2d 966 (1978), a grant of immunity is governed by the Rule of Criminal Procedure only in the absence of applicable statute. Rule 58 [which used to authorize transactional immunity] was * * * amended to conform to the statute * *
State v. McGee, 95 N.M. 317, 320, 621 P.2d 1129, 1132 (Ct.App.1980). The trial court, therefore, under both Crim.P. Rule 58 and Section 31-6-15, only had the authority to grant the witness use immunity.
“Use” immunity means that “the witness’ testimony or any information derived from such testimony may never be used against the witness in a subsequent prosecution. Under a statute authorizing ‘use and derivative use’ immunity, the witness may still be prosecuted for the offense to which the compelled testimony relates. However, the prosecution would have the burden of proving that the evidence it proposed to use was ‘derived from a legitimate source wholly independent of the compelled testimony.’ ”
Sanchez, 98 N.M. 428, 433 n. 3, 649 P.2d 496, 501 n. 3 (quoting 3 Wharton’s Criminal Procedure § 409, at 94 (12th ed. C. Torcia 1975)).
A witness may not be given permission to testify untruthfully in any immunity order.
There is no basis in the statute [§ 31-6-15(A) ] for the contention that the legislative intent was other than to have a witness testify truthfully whatever his status when he takes the witness stand. Furthermore, the very purpose of the granting of immunity is to reach the truth. * * *
Implicit in Section 31-6-15(A) is the fact that a witness must testify truthfully or be subject to being prosecuted (1) for perjury committed in such testimony or in producing such evidence, or (2) for contempt for failure to give an answer or produce evidence. To hold otherwise would make this statute meaningless.
State v. Boeglin, 100 N.M. 470, 471, 672 P.2d 643, 644 (1983) (citations omitted). The trial court cannot give a witness permission to perjure himself by an immunity order under Crim.P. Rule 58, Evid. Rule 412, and Section 31-6-15.
It appears that immunity may be given from prosecution for past perjury. There is no New Mexico case on the subject, but other jurisdictions have ruled on the issue. In People v. Baker, 88 Cal.App.3d 115, 124, 151 Cal.Rptr. 362, 367 (1978), the court held:
It is clear that the order granting immunity from prosecution for any perjury committed up to, but not including the trial testimony, was proper. [The witness] was not forced to lie at trial * * * for she was granted immunity from prosecution for perjury she committed before the Grand Jury. [The witness’] only obligation was to testify truthfully at trial.
In In re Contempt Findings Against Schultz, 428 N.E.2d 1284 (Ind.App.1981), the court, after finding that its statute authorized only use immunity, held that it did not protect defendant from perjury committed during his testimony. The court did find, however, that “[a]s to any perjury antedating the immunity order, the [trial] court’s grant of use immunity would apparently protect [defendant] from being prosecuted for this perjury based upon the testimony he was compelled to give at [his co-defendant’s] trial.” 428 N.E.2d at 1289-1290. In State v. Richards, 457 So.2d 1124 (Fla.App.1984), the court held that witnesses must testify when their testimony is immunized. The court held that:
[w]hile any testimony which these witnesses give at trial under the grant of immunity may not be used as evidence against them in a prosecution for peijury by making inconsistent or contradictory statements, these witnesses are not entitled to immunity from prosecution. They may be prosecuted for committing perjury during their trial testimony providing only that their trial testimony is proved to be perjurious by independent proof rather than by merely showing that it conflicts with prior testimony, and they may be prosecuted for perjury for making any previous sworn statement so long as the statement is proved perjurious by other than the use of the witnesses’ immunized trial testimony.
Id. at 1125 (emphasis in original). The trial court’s intent may have been to grant the witness immunity for prior perjurious statements. The immunity order, however, had the effect of immunizing the witness from prosecution for false statements he might make at trial.
While it seems that immunity may be given for past perjury, our statute clearly prohibits immunity from perjury in connection with present' testimony. The trial court, therefore, had authority to give Barela immunity for past perjury, but not for perjury committed during defendant’s trial.
Either the court gave the witness use immunity consistent with Crim.P. Rule 58, Evid. Rule 412, and Section 31-6-15, or it did not. If it did not, it appears to have given transactional immunity, or immunity from perjury committed in the cause, not authorized under New Mexico law. As noted previously, Crim.P. Rule 58 and Evid. Rule 412 create a procedure for use immunity. The witness in this case was granted “immunity from prosecution [for] perjury as a result of his testimony in this cause based on Rule 58 Criminal Procedure.” Criminal P. Rule 58 was cited as the basis for this order in both its written and oral forms.
The parties also seemed to understand that transactional immunity was granted to the witness. This is evident from the questioning of the witness by both the prosecutor and defense counsel:
DEFENSE COUNSEL: That’s right, Mr. Barela, so you did get some promise for your testimony—
BARELA: That I wouldn’t get charged for this charge.
DEFENSE COUNSEL: And you can’t be prosecuted for perjury, isn’t that right?
BARELA: Yeah.
DEFENSE COUNSEL: Even if you lie, but you stood up there and took an oath to tell the truth, right?
BARELA: Yeah.
DEFENSE COUNSEL: Even though you know you can’t be prosecuted for lying. Isn’t that right?
BARELA: Yes.
A similar exchange took place later with the prosecutor:
PROSECUTOR: Now, Mr. Barela, the immunity you received for testifying here today, that goes to anything you say here today while you’re on the stand. Is that right?
BARELA: Yes.
PROSECUTOR: And that was done on the advice of your attorney, right?
BARELA: Yes.
PROSECUTOR: And the immunity you were given didn’t have anything to do with past charges did it? Or does it? [Pause] The immunity you were given for testifying today, anything you might say here today, does not apply to past charges, right?
BARELA: I don’t think so.
The parties appear to view the order as granting the witness immunity from a perjury prosecution which might result from testimony given at the trial of defendant. In other words, the parties seemed to think Barela was given immunity for his testimony at the trial, not for the statements he made prior to trial. If this is the case, Barela was, in effect, given a “license to lie” on the stand.
An immunity order which gives the witness a “license to lie” is plain error and defendant’s conviction, based on such testimony, must be reversed. Plain error was defined in State v. Marquez, 87 N.M. 57, 529 P.2d 283 (Ct.App.1974). “ ‘Plain error’ has been characterized in various ways such as ‘grave errors which seriously affect substantial rights of the accused,’ ‘errors that result in a clear miscarriage of justice,’ errors that ‘are obvious or * * * otherwise seriously affect the fairness, integrity, or public reputation of judicial proceedings.’ ” Id. at 61, 529 P.2d at 287, quoting United States v. Campbell, 419 F.2d 1144 (5th Cir.1969). A plain error claim may be raised for the first time on appeal. NMSA 1978, Evid.R. 103(d) (Repl.Pamp.1983); State v. Lara, 88 N.M. 233, 539 P.2d 623 (Ct.App.1975). Under Evid. Rule 103(d), the claim must relate to some evidentiary ruling of the trial court. State v. Wall, 94 N.M. 169, 608 P.2d 145 (1980); State v. Sanchez, 86 N.M. 713, 526 P.2d 1306 (Ct.App.1974). That was the case here because the witness’ testimony was only available because of the immunity ruling. Otherwise, the testimony would not have existed at all. Defendant’s claim relates to an evidentiary ruling because it is based on an order to a witness to testify. It may be raised for the first time on appeal.
“ ‘[T]he plain error rule should be applied with caution, and invoked only to avoid a miscarriage of justice.’ ” State v. Marquez, 87 N.M. 57, 61, 529 P.2d 283, 287, quoting United States v. Robinson, 419 F.2d 1109 (8th Cir.1969). In this case, it would be a miscarriage of justice to allow a conviction possibly based on court-authorized perjury to stand. Such a conviction would be based on “obvious error” and would “seriously affect the integrity of the judicial proceedings.” See Marquez. If the witness was given immunity from prosecution for perjury committed at defendant’s trial, it is clear that plain error occurred.
Therefore, defendant’s conviction is reversed and the cause remanded for a new trial.
IT IS SO ORDERED.
BIVINS and GARCIA, JJ., concur.