In any criminal proceeding before a court or grand jury, if a person refuses to answer a question or produce evidence of any other kind on the ground that he may be incriminated thereby and if the prosecuting attorney, in writing, requests the court to order that person to answer the question or produce the evidence, the court may so order and that person shall comply with the order. When the court denies such a request, the court shall state its reasons for denial in writing. After complying, such testimony or evidence, or any information directly or indirectly derived from such testimony or evidence, shall not be used against the person in any proceeding or prosecution for a crime or offense concerning which he gave answer or produced evidence under court order. However, he may nevertheless be prosecuted or subjected to penalty or forfeiture for any perjury, false swearing or contempt committed in answering, or failing to answer, or in producing, or failing to produce, evidence in accordance with the order. If a person refuses to testify after being granted immunity and after being ordered to testify as aforesaid, he may be adjudged in contempt and committed to the county jail. If the grand jury before which he was ordered to testify has been dissolved, he may then purge himself by testifying before the court.
A.R.S. § 13-4064