A Petition for a Writ of Habeas Corpus Under 28 U.S.C. Sec. 2241 is a legal document that allows a person who is being held in custody to challenge the legality of their detention. This petition is filed by an individual who is challenging the jurisdiction or authority of the person or agency detaining them, or the procedure used to detain them. It is a civil action that is filed in federal court. There are two primary types of Petition for a Writ of Habeas Corpus Under 28 U.S.C. Sec. 2241: a petition for habeas corpus ad prosequendum, and a petition for habeas corpus ad subjiciendum. A petition for habeas corpus ad prosequendum is filed when a person is being detained by the federal government. This petition is used to ask the court for an order to produce the detainee in court for a hearing. A petition for habeas corpus ad subjiciendum is filed when a person is being held in custody by state or local authorities. This petition is used to ask the court for an order requiring the custodian to provide a legal basis for the detention, or to release the detainee. In both cases, the court will then rule on the legality of the detention, and if the court finds that the detention is illegal, the court will issue a writ of habeas corpus ordering the custodian to release the detainee.