delivered the opinion of the Court.
On August 21, 1935, Pedro Canales Clemente was sentenced by the Municipal Court of Río Piedras to pay a. fine of $50 or in default thereof to spend one day in jail for every dollar that- he should fail to pay. Having* failed to pay the fine he was committed to the Municipal Jail of Río Piedras. The record does not show whether or not the defendant was represented by counsel at the trial.
On August 22, 1935, the defendant appeared by his attorney before the municipal court to request a reconsideration and annulment of the judgment rendered the day before, on the ground that, since he was under 16 years of age on the date on which he was sentenced, the municipal court did not have jurisdiction to entertain the case or to render judgment against the defendant. A certificate of the Registry *749of Vital Statistics to prove the age of the defendant was attached to the petition. The municipal court denied the motion for reconsideration and the defendant was again committed to jail.
Jovita Clemente, the mother of the defendant, filed a petition for a writ of habeas corpus in the District Court of San Juan, in which she requests that the judgment rendered by the municipal court be declared null and void because the said court had no jurisdiction to render it. The district court rendered judgment in accordance with the prayer of the petition and ordered that the defendant be immediately set free. The district attorney took the present appeal.
The fiscal argues that the district court had no jurisdiction to review by habeas corpus the judgment of the municipal court, and that the said judgment cannot be attacked collaterally.
There is no controversy between the parties as to the principal fact, that is, that on the date of the judgment the defendant was under 16 years of age. And both parties agree that the municipal court did not have jurisdiction to render the judgment aud still less to order the commitment of the minor to the common jail intended for the confinement of adult criminals. The only question debated is whether or not, because of the fact that he did not raise the question of want of jurisdiction at the trial and before judgment was rendered, the defendant in this case should be deprived of the constitutional right which every person who is confined in a prison has to request that a competent court investigate the legality of his detention and that it set him free by means of a writ of habeas corpus, if the investigation should show that the order of imprisonment was issued by a court without jurisdiction.
The general rule is that the writ of habeas corpus cannot be used to correct mere procedural errors or irregularities of procedure, unless they involve the question of lack of *750jurisdiction of the court which rendered the judgment and ordered the commitment of the petitioner for the writ. It is a well established doctrine that when a court exceeds its authority or exercises powers which the law has not granted it, the judgment thus rendered is void and the imprisonment ordered in execution of that judgment is unlawful and as such may he annulled by means of a habeas corpus proceeding-. See: Ex parte De la Rosa, 7 P.R.R. 353 and Ex parte Díaz, 7 P.R.R. 153; In Re Luis Oteiza y Cortés, 136 U.S. 330, 34 L. ed. 464; Ex parte Siebold, 100 U.S. 371, 25 L. ed. 717; In re Frederich, 149 U.S. 70, 37 L. ed. 653; Riggins v. United States, 199 U.S. 547, 50 L. ed. 303.
In his work on Constitutional Limitations Justice Cooley states:
“Where a party who is in confinement under judicial process is brought up on habeas corpus, the court or judge before whom he is returned will inquire: 1. Whether the court or officer issuing the process under which he is detained had jurisdiction of the case, and has acted within that jurisdiction in issuing such process. If so, mere irregularities or errors of judgment in the exercise of that jurisdiction must be disregarded on this writ, and must be corrected either by the court issuing the process, or on regular appellate proceedings. ’ ’ Page 424.
Section 1 of Act no. 37 of 1915 (Laws, p. 71), which established a system of juvenile courts in Puerto Rico, confers on the said courts “exclusive original jurisdiction of all cases of juvenile delinquency and dependency” in which the defendant is a minor under 16 years of age. The juvenile courts established in each one of the judicial districts of the Island are presided over by the judge of the respective district. The municipal judges have absolutely no jurisdiction to entertain cases in which the delinquent is under 16 years of age, and may act as judges of the juvenile court only when they are appointed by the Attorney General in case of the absence, disability, ox disqualification of the district judge.
The fundamental purpose of the system of juvenile courts is to treat and consider minors under 16 years of age not *751as criminals but as wards of the' State, which is bound to reform and educate them in order to prevent them from continuing on the road of crime. For this reason the act provides that the hearing of the case shall be held in private; that the punishments imposed by law on adults shall be applied discretionally in the cases of juvenile delinquents; that the juvenile courts shall have the power to set aside or suspend the execution of judgments; and that no order or judgment rendered by the court against a child shall be admitted as evidence in any civil or criminal proceeding against the same child.
The greatest protection which the act affords the delinquent minor is contained in Section 23, which provides “no child under sixteen (16) years of age shall be incarcerated in any common jail together with adult criminals therein confined,” with the evident purpose of avoiding the irreparable damage which would be caused the minor as the result of contact and association with persons already inured to crime. And Section 31, completing the purpose of Section 23 provides:
“Under no circumstance, except by order of the court, shall a child under the age of 16 years be incarcerated in any common prison, jail or lock-up, and any officer or person violating this provision of law, shall be guilty of misdemeanor and punishable, etc.”
There is no doubt that even though the municipal court had jurisdiction of the offense imputed to Pedro Canales Clemente, that is, selling tickets for an illegal game of “bolita”, it did not have jurisdiction over the person of the minor, -nor could it acquire such jurisdiction because of the mere fact that the said minor did not raise the question of lack of jurisdiction until after the judgment had been rendered and his confinement ordered. Jurisdiction over the persons of delinquents under 16 years of age rests exclusively with the juvenile courts and these are the only ones which may render a valid judgment against the minor and order his imprisonment in a common jail, but always subject to the *752condition that the minor will be confined in a place separate from the adults therein confined.
In the instant case the attention of the trial judge was called to his lack of jurisdiction in time for him to correct his error by reconsidering and vacating the judgment and sending the case to the Juvenile Court for the District of San Juan for proceedings in accordance with the law. A birth certificate of the minor showing that the latter was born on April 19, 1921, and that therefore on the date on which he was sentenced and confined in jail he was only 14 years, 4 months and 2 days old, was offered to the municipal judge. That certificate, which is prima facie evidence of the age of the prisoner, was sent up to the district court as a part of the record in the habeas corpus proceeding and also appears in the record of the present appeal.
Since the principal purpose of the remedy of habeas corpus is to investigate the legality of the detention of a person, the district court could not ignore the fact that Pedro Cana-les Clemente, a minor under 16 years of age, had been convicted by a municipal court which lacked jurisdiction over his person. And still less could it ignore the fact that this minor, in violation of the definite provisions of Sections 23 and 31 of the act, supra, was confined, by order of that same municipal court, in a common jail, to which a minor could not be sent lawfully, under any circumstances, except by order of the Juvenile Court for the District of San Juan.
We are not convinced by the argument of the fiscal as to the scope and application of Section 19 of Act no. 37 of 1915 (Laws, p. 72), as amended by Act no. 10 of April 6, 1916 (Laws, p. 42). The said section reads as follows:
“Section 19. — If the age of any child appearing before the court should be brought into question, the court shall be final judge as to whether it has jurisdiction of the case; and for the purpose of passing judgment on the age of such child the court may request a certified copy of the birth record thereof, and may summon as a witness any physician employed by The People of Porto Rico in the *753Public Health Service or in any of Insular penal institutions. Said physicians shall not receive any fees for services so rendered. Whenever an officer or any other person arresting a child shall be in doubt as to the age of the said child, he shall proceed with the child according to the provisions of this Act, in the same manner as if the-child was unquestionably under the age of sixteen years.
“The judge of any juvenile court may require any physician1 mentioned in the first paragraph of this Section to make without charge, such physical or mental examinations of children affected by this Act as he may deem necessary. Such judge may also hear the report of any other physician authorized to practice as such in Puerto Rico. ’ ’
Tlie provisions copied are so clear that they do not need judicial -interpretation. The court to which this Section refers is the Juvenile Court. It is that court, and not the municipal court, which has jurisdiction to render a final decision as to the age of the minor brought before it, if his age should be in controversy. The duty of the municipal court in case of doubt as to the age of the minor is to give him the benefit of the doubt, to treat him as if he were unquestionably under 16 years of age and to transfer the case to the corresponding Juvenile Court. And that is .what the Municipal Court of Río Piedras should have done and did not do when it was asked to reconsider its judgment and when prima facie evidence was presented to it to show that the minor was not yet 16 years old'.
For the reasons stated, and especially because we are of the opinion that the municipal court did not have jurisdiction over the person of the minor, the judgment appealed fronoi is affirmed.
Mr. Chief Justice Del Toro and Mr. Justice Cordova Dávila took no part in the decision of this case.