Immunity from prosecution occurs when a prosecutor grants immunity, usually to a witness in exchange for testimony or production of other evidence. It is immunity because the prosecutor essentially agrees to never prosecute the crime that the witness might have committed in exchange for said evidence.
The prosecution may grant immunity in one of two forms. Transactional immunity (colloquially known as “blanket” or “total” immunity) completely protects the witness from future prosecution for crimes related to his or her testimony. “Use and derivative use” immunity prevents the prosecution only from using the witness’s own testimony or any evidence derived from the testimony against the witness. However, should the prosecutor acquire evidence substantiating the supposed crime—independently of the witness’s testimony—the witness may then be prosecuted for same.
While prosecutors at the state level may offer a witness either transactional or use and derivative use immunity, at the federal level, use and derivative use immunity is the norm.
 Grand Jury testimony
Witnesses compelled by subpoena to appear before a grand jury are entitled to receive immunity in exchange for their testimony. The grant of immunity impairs the witness’s right to invoke the Fifth Amendment protection against self-incrimination as a legal basis for refusing to testify. If a witness who has been granted immunity nevertheless refuses to offer testimony, he may be held in contempt of the court that issued the subpoena.
In Kastigar v. United States, 406 U.S. 441 (1972), the Supreme Court confronted the issue of which type of immunity, use or transactional, is constitutionally required in order to compel testimony. The Court ruled that the grant of “use and derivative use” immunity is sufficient.
Despite the ruling in Kastigar, the type of immunity required to compel testimony depends on the law of the applicable jurisdiction. Many states, such as New York, do more than the Federal Constitution requires and mandate that transactional immunity be accorded to compelled witnesses.
In states where a defendant has a right to testify on his own behalf at a grand jury proceeding, waiver of immunity is invariably a condition of that right.