Petitioner James Edward Jones filed a petition for writ of habeas corpus to challenge his continued detention under a sentence for direct criminal contempt. We treat the petition as a timely filed notice of appeal of the contempt conviction under Florida Rule of Appellate Procedure 9.040(c), and we reverse.
Jones was subpoenaed in State v. Arnold, case no. 08CF014103AMB, by counsel representing the defendant, who was being tried for first-degree murder. According to Jones’s petition, Arnold’s defense was that he had left the victim alive in Jones’s company. Jones appeared, but refused to answer defense counsel’s questions, asserting his Fifth Amendment privilege against compulsory self-incrimination.
The trial court found Jones to be in direct criminal contempt for refusing to testify and sentenced him to five months and twenty-nine days. The trial court’s three-page contempt judgment detailed how it had advised Jones that he could not assert his Fifth Amendment right and required him to answer defense counsel’s questions, but Jones refused. The trial court asked him to show cause why he should not be adjudged guilty of direct criminal contempt, and whether he had any evidence of excusing or mitigating circumstances, but he refused to respond. According to Jones’s petition, at the time, neither the trial court nor the state advised him that he would be granted immunity in connection with his testimony.
Jones filed a motion for rehearing in which he argued that the trial court overlooked the fact that only the prosecuting attorney can offer immunity, but the trial court denied the motion.
The lengthy contempt judgment was silent as to whether the state had agreed to grant Jones immunity for his testimony. While section 914.04, Florida Statutes (2010) (providing immunity for one served with a subpoena), does not appear to limit its application to persons who are subpoenaed by the state, case law makes it clear that the purpose of the statute is to aid the state; a defendant cannot immunize a witness in order to secure the witness’s compulsory testimony. Fountaine v. State, 460 So.2d 553 (Fla. 2d DCA 1984) (affirming conviction and explaining that section 914.04 is designed to insulate witness against incriminating effect of testimony compelled by the state). The Fountaine court explained as follows:
We hold that the self-executing feature of section 914.04 discussed in Jenny [v. State, 447 So.2d 1351 (Fla.1984),] is limited to cases where the state subpoenas a witness to testify before the state attorney, grand jury, or before a court having felony jurisdiction. It cannot be invoked by the defendant to immunize a witness. Therefore, we find no error in the trial court’s refusal to grant immunity to Powers [a prospective defense witness who refused to testify without a grant of immunity], who was subpoenaed to testify on behalf of the defendant. To hold otherwise would enable defendants to seriously impede the prosecution of crime.
*591Id. at 555. Neither do trial courts, under ordinary circumstances, have any inherent power to grant use immunity to a defense witness over the state’s objection. State v. Montgomery, 467 So.2d 387, 395 (Fla. 3d DCA 1985) (granting petition for writ of prohibition).1
Because nothing in the petition or in the trial court’s contempt judgment suggested that the state had agreed to grant Jones immunity if he were to testify in the Arnold prosecution, this court issued an order to show cause. The state has responded that, in light of Fountaine and Montgomery, it cannot show cause why the petition should not be granted.
Accordingly, we reverse Jones’s conviction and sentence for direct criminal contempt in L.T. case no. 2010MM021580A, but we direct him to be released solely from his incarceration in connection with the instant contempt case.
This decision should not be interpreted to affect Jones’s custody, to the extent he is incarcerated for any other reason. Jones indicated in his petition that he was in custody in connection with an unrelated case when he was subpoenaed to testify in the Arnold prosecution; the state’s response indicates that he is being held in custody on unrelated charges in L.T. case no. 2010CF010050. We order only that Jones not be held any longer in connection with L.T. case no. 2010MM021580A.
Reversed.
HAZOURI, GERBER and LEVINE, JJ., concur.. The Montgomery court explained there is an exception in cases of prosecutorial misconduct: when a defendant’s right to subpoena a . witness, and to have the witness available as the defendant finds the witness, is violated by prosecutorial misconduct, then a judgment of acquittal is warranted, unless the state agrees to cure the constitutional violation with a grant of use immunity pursuant to section 914.04. 467 So.2d at 392.