A court may issue a writ of habeas corpus, when necessary, to bring before it a prisoner for trial in a cause pending in such court, or to testify as a witness when his personal attendance is deemed necessary for the attainment of justice.
Whenever, under this section or under any other section in this chapter, a court issues a writ of habeas corpus ordering before it a prisoner confined in any penal or correctional institution under the control of the Department of Health and Human Services or the Department of Corrections, or confined in any county jail, its order as to the transportation of the prisoner to and from the court must be directed to the sheriff of the county in which the court is located. It is the responsibility of the sheriff or any one or more of the sheriff's authorized deputies pursuant to any such order to safely transport a prisoner to and from the court and to provide safe and secure custody of the prisoner during the proceedings, as directed by the court. At the time of removal of a prisoner from an institution, the transporting officer shall leave with the head of the institution an attested copy of the order of the court, and upon return of the prisoner shall note that return on the copy. This paragraph as it relates to the responsibility for transportation is applicable to transfers from the county jail to any other county jail or to a state correctional facility under Title 34-A, section 1405. [2007, c. 653, Pt. A, §4 (AMD).]
Any prisoner who escapes from custody of the sheriff or any of his deputies or any other law enforcement officer following removal for appearance in court, from a penal or correctional institution or from a county jail, and prior to return thereto, shall be chargeable with escape from the penal or correctional institution or county jail from which he was removed, and shall be punished in accordance with Title 17-A, section 755. [1975, c. 740, §1-A (RPR).]