Autopsy in Jewish law:
It is Biblically forbidden for an autopsy to be performed onto a Jewish body. This applies even if the autopsy is desired to be performed for the sake of advancement of medical science, and for possible use in preventing future deaths. One must thus do all in his power while alive to prevent his body from having an autopsy in case of death, and certainly may not sign to give his body away for autopsy on behalf of medical science. [If one did so, his wishes are not to be obeyed.] If, however, the autopsy can possibly bring a cure to a person who is currently ill, then it is permitted to be performed. [Some however say that this only applies if the person in need of a cure is in the same hospital as the autopsy patient. Practically, a Rav is to be contacted in all cases that the autopsy can possibly lead to a cure for someone who is currently ill.]
Autopsy as part of a murder investigation to help capture the murderer: It is permitted for an autopsy to be performed as part of a murder investigation for the sake of capturing and/or indicting the murderer and avenging his death. Practically, a Rav is to be contacted in all cases that the autopsy can possibly lead to solving a murder investigation.
Autopsy for the sake of removing a pacemaker and the like: It is permitted to remove implanted medical devices from the body, such as a pacemaker, for the sake of future use in other patients.
Desecrating Shabbos to prevent autopsy: It is permitted to transgress Shabbos and perform Rabbinical Melacha in order to prevent an autopsy. See Chapter 2 Halacha 8 for the full details of this matter!
Autopsy on a gentile corpse: It is disputed in Poskim as to whether there is a prohibition to benefit from the body of a gentile. Practically, some Poskim are lenient to allow benefiting from a gentile’s body for the sake of medical science.
 Noda Beyehuda Tinyana Y.D. 210; Chasam Sofer 336, brought in Pischeiy Teshuvah 363:5; Sheilas Yaavetz 41; Shagas Aryeh Chadashos 6; Kesav Sofer 175; Maharam Shick 344-347; Binyan Tziyon 170-171; Chazon Ish Ohalos 22:32; Gesher Hachaim 1:3-12; Seridei Eish 2:119; Yabia Omer 3:23; Igros Moshe Y.D. 1:151; Tzitz Eliezer 4:14; Minchas Yitzchak 5:9; See Gesher Hachaim 5:6; Darkei Chesed 10; Nishmas Avraham 2:517-520; Kovetz Hamayan 7 and Asia 4:32; See Nitei Gavriel 48:16
Regarding performing an autopsy on a Nefel: It is forbidden to perform an autopsy on a Nefel. In a case of need, a Rav is to be contacted. [See Maharam Shick Y.D. 323; Binyan Tziyon 119; Nishmas Avraham Volume 2 p. 522; Nitei Gavriel 132:38; 41 footnote 55]
Watching an autopsy: Some Poskim rule it is permitted to watch a live autopsy. [Chelkas Yaakov 1:84; Har Tzevi 288] Others rule it is forbidden. [Maharam Shick 344; Rav SZ”A, brought in Nishmas Avraham ibid p. 517 and 522]
Removing a heart pacer and reusing it: See Nishmas Avraham p. 523-526 in name of Poskim; Binyan Av [of Rav Batzri]
 The reason: This is forbidden for one of several reason: 1) This defiles the body, and is considered Bizuiy Hameis, which is Biblically forbidden. [Noda Beyehuda and Chasam Sofer ibid] 2) It delays the burial and transgresses Lo Salin. 3) It benefits from the dead, which is Biblically forbidden. 4) It causes pain to the soul who witnesses all that is occurring to his body. [Tosfos Yom Tov Avos 2:7; Rashba 1:369; Sefer Chassidim 1163; See Gesher Hachaim 1:5] See Nishmas Avraham ibid p. 518
 Noda Beyehuda Tinyana Y.D. 210; Chasam Sofer 336, brought in Pischeiy Teshuvah 363:5; Poskim ibid
Other opinions: Some Poskim rule it is permitted to perform an autopsy for the sake of medical science. [Mishpitei Uziel Y.D. 25-26]
 Chasam Sofer 336, brought in Pischeiy Teshuvah 363:5; Maharam Shick 347; Gesher Hachaim 5:6; Igros Moshe Y.D. 3:140
Other opinions: Some Poskim rule it is permitted to perform an autopsy for the sake of medical science if the deceased gave permission prior to his passing. [Binyan Tziyon ibid 176; Tzitz Eliezer 4:14; See Chelkas Yaakov 4:39; Nishmas Avraham ibid p. 521]
 Gesher Hachaim 5:6 based on Michaber 348:3
 Chasam Sofer ibid and Nodah Beyehuda ibid, brought in Pischeiy Teshuvah ibid; Poskim ibid; Gesher Hachaim 5:6
Other opinions: Some Poskim rule it is forbidden to perform an autopsy for the sake of medical science even in such a case. [Binyan Tziyon ibid]
Regarding performing an autopsy for the sake of saving a limb of a patient: See Nishmas Avraham ibid p. 520 in name of Poskim.
 Nishmas Avraham ibid, as hospitals do not share medical information right away, and hence it is only considered a true “for sake of healing” when the patient is in the same hospital; See Igros Moshe ibid; See Chazon Ish ibid that allowances due to Sakana is only by current events and not possible future events
 See Nishmas Avraham ibid
 Poskim in Nitei Gavriel 48 footnote 20
 See Nishmas Avraham p. 523-526 in name of Poskim; Igros Moshe; Rav SZ”A; Tzitz Eliezer; Shevet Halevi 7:189; Yabia Omer 10:50; Binyan Av [of Rav Batzri]
 The reason: As the item was never placed in the body with intent for him to be buried with it, and hence does not receive a benefit prohibition.
 See SSH”K 64:13; Piskeiy Teshuvos 311:1 [old edition and new edition]; Nishmas Avraham 2:533
 See Admur 311:2 and 4 that one can take the body from a Karmalis in order to prevent erosion or cremation. [Only by Muktzah were the Sages stringent to limit its desecration and only allow its movement if there is a permitted item on it, as explained in Admur 311:3.]; See SSH”K 64:13; Piskeiy Teshuvos 311:1 [old edition and new edition]; Nishmas Avraham 2:533 in name of Chelkas Yaakov
 See Chapter 4 Halacha C!
 Even Shoham 30, brought in Pischeiy Teshuvah 349:1; Igros Moshe Y.D. 1:229-6; Yaskil Avdi 6:19; Rav SZ”A, brought in Nishmas Avraham ibid; This follows the lenient opinions brought above who hold it is not prohibited at all, or is merely a Rabbinical prohibition. However according to those opinions who hold it is a Biblical prohibition, it is forbidden to make use of the body even for the benefit of medical science. [See Darkei Moshe Y.D. 368:4]