“The writ of habeas corpus has been defined, or rather described, as That legal process which is employed for the summary vindication of the right of personal liberty when illegally restrained.’— Hurd on Habeas Corpus, 129. It is a common-law writ, employed by the courts of common law, of superior ju*428risdiction, and the court'of chancery, before the enactment of statutes regulating its use. These statutes have not been construed as diminishing the common-law jurisdiction of the courts in the employment of the writ. They are regarded as 'increasing the facilities for procuring it, enlarging the class of officers having jurisdiction in respect of it, imposing penalties for refusing to grant it, or to obey it, and providing for a speedy return, and prompt trial and discharge of the person, if not held according to the law of the land.’—People, etc., v. Liscomb, 60 N. Y. 566 [19 Am. Rep. 211]. The statutes of this state do- not extend to the writ as a common-law remedy, employed by the courts of superior jurisdiction, or the court of chancery, returnable into court, and heard in term time. They treat of it and confer jurisdiction as a remedy for illegal imprisonment to be pursued by judicial officers, differing in degree, and of different general jurisdiction, returnable not into court, but in vacation, and heard by the officer as a magistrate, and not as a court.
“A superior court, in the exercise of its common-law jurisdiction, may employ the writ of habeas corpus to bring before it the body of a person illegally imprisoned,. and, if the imprisonment is under legal process, or the judgment or sentence of a court of inferior jurisdiction, may award a writ of certiorari, removing the record. The proceeding is then in its nature appellate, and there may be an inquiry into the regularity of the process, judgment, or sentence. When, however, the writ is sued out under the statute, and the jurisdiction conferred by the statute on a single magistrate is to be exercised in vacation, the proceeding is not in its nature appellate, but rather original, and the validity of the process, judgment, or sentence is drawn in question collaterally. The general principle, then, prevails that, *429when a record or process is collaterally assailed, it must "be for illegality, not for error or irregularity. The statute affirms this principle, in declaring that, on the return to a writ of habeas corpus, there is no ‘authority to inquire into the legality or justice of any order, judgment, decree or process of any court legally constituted, or into the justice or propriety of any commitment for contempt made by a court, officer or body, according to law, and charged in such commitment.’—Code of 1876, § 4961. The word ‘legality’ is here employed in the sense of ‘regularity,’ and not in a sense which would exclude an inquiry into the jurisdiction of the court or officer issuing the process or rendering the judgment. If jurisdiction has not attached, if the process or judgment is therefore without authority of law, it is not only irregular, but illegal. But if jurisdiction has attached, .and there is departure from, or a neglect to observe, the prescribed mode of procedure, the process or judgment is merely irregular. However gross may be the irregularity, the correction of it is not the function of a writ ■of habeas corpus prosecuted under the statute.—Ex parte McKivett, 55 Ala. 236.” Kirby v. State, 62 Ala. 51, 54, 55.
The writ in the present case was issued under the ■statute, by the circuit judge, and the jurisdiction thereby conferred on him to hear the petition was original, and not appellate; and he was only authorized to determine the validity of the process under which the petitioner Avas held, and could not inquire into any errors or irregularities. The statute (section 7032 of the ■Code of 1907) expressly provides that:
“No court, chancellor, or judge, on the return of the writ of habeas corpus, has authority to inquire into the regularity or justice of any order, judgment, decree, or process, of any court legally constituted, or into the jus*430tice or propriety of any commitment for contempt made by a court, officer, or body, according to law, and charged in such commitment.”—Towery v. State, 143 Ala. 59, 39 South. 310.
The petition for habeas corpus, being under the statute, was in the nature of a collateral attack upon the judgment or order of tint law and equity court, a court with powers equal to those of the circuit court, and whose judge has co-ordinate powers, in Morgan county, with the circuit judge. This being true, the-said D. W. Speake had no power or authority to question the orders or judgments of the law and equity court upon habeas corpus, except in the event that the said law and equity court, or the judge thereof, had no jurisdiction to act in the premises, or to render the judgment or issue the order in question.—Fourment v. State, 155 Ala. 109, 46 South. 266; Sneed v. State, 157 Ala. 8, 47 South. 1028.
It cannot be successfully contended that the law and', equity court did not have jurisdiction to impose the sentence mentioned in the amended petition for habeas, corpus; nor does said amended petition charge that the petitioner was entitled to a discharge, by reason of some-act, omission, or event subsequent to the sentence.
Section 7014 provides for the issuance of the writ unless it appears from the petition itself, or from the documents thereto annexed, that the person imprisoned or restrained is not, under the provisions of the chapter,, entitled to the benefit of the Avrit. In other words, if' the petition shows upon its face that the petitioner is not entitled to the writ, the officer to whom the petition, is addressed should not issue the writ or direct the precept to the sheriff or constable.
The amended petition showing upon its face that the-petitioner was sentenced by the law and equity court,. *431acting within its jurisdiction, the circuit judge improperly issued the writ of habeas corpus; and the writ of prohibition is the proper remedy to restrain said circuit judge from further proceeding in the premises. The amended petition for the writ of habeas corpus failing to give the circuit judge jurisdiction to act in the instant case, the writ of prohibition will be awarded, notwithstanding the respondent may have jurisdiction to issue writs of habeas corpus in proper cases.—Ex parte State, ex rel. Attorney General, 150 Ala. 489, 43 South. 490, 10 L. R. A. (N. S.) 1129, 124 Am. St. Rep. 79.
Let the writ of prohibition he awarded.
Petition granted.
All the Justices concur.