The petitioner stressfully contends that the father, being a fit and suitable person, has sole right to the custody of his child “as a rule of law,” and that therefore a controversy respecting the child’s custody such as would confer jurisdiction upon the juvenile court cannot arise in the absence of proof of abandonment or other special fact not here appearing.
This position cannot be sustained. The right of petitioner to the custody of his child is not at issue on this appeal. The sole question is one of procedure which, on this record, is jurisdictional. Furthermore, the contention is made in the middle of a controversy in respect to the custody of said infant. The cause of petitioner may be just and the contention of respondents may be unfounded and unwarranted—nonetheless, there is a controversy. Otherwise there would be no need to seek the aid of the courts.
We have four separate statutory provisions respecting the manner of determining the right to the custody of an infant when custody is the only question at issue. G.S. 17-39, G.S. 50-13, and G.S. 110-21 (3). Any apparent conflict or inconsistency in the provisions of these statutes has been reconciled and harmonized in former decisions of this Court.
The provisions of the first two, G.S. 17-39 and G.S. 50-13, may be invoked only in cases where the custody of a child is the subject of controversy between its parents.
When the parents are living in a state of separation without being divorced a controversy between them over the custody of a child born of the marriage may be adjudicated under a writ of habeas corpus. G.S. 17-39; In re Blake, 184 N. C. 278, 114 S. E. 294; McEachern v. McEachern, 210 N. C. 98, 185 S. E. 684. This writ is an extraordinary peremptory criminal process not ordinarily available in a civil proceeding. It is not to be used “as a claim and delivery of the person,” In re Parker, 144 N. C. 170, In re Young, 222 N. C. 708, 24 S. E. (2) 539, and “it is not available as between other parties, nor as between divorced parents.” In re Young, supra; In re Parker, supra; In re Gibson, 222 N. C. 350, 23 S. E. (2) 50; In re Ogden, 211 N. C. 100, 189 S. E. 119; In re Albertson, 205 N. C. 742, 172 S. E. 411; McEachern v. McEachern, supra. It is not to be used except when the undivorced parents of the child are living in a state of separation. While there was some departure *632from this rule prior to the enactment of the Juvenile Court Act (Chap. 97, P. L. 1919, now Art. 2, Chap. 110, General Statutes), Latham v. Ellis, 116 N. C. 30; In re Fain, 172 N. C. 790, 90 S. E. 928, this Court has been careful to limit its use to this one purpose since the enactment of the latter statute providing a ready and adequate remedy in other cases.
So soon as the “state of separation” between husband and wife resolves itself into, brings about, or is followed by an action for divorce in which a complaint has been filed, the jurisdiction of the court acquired under a writ of habeas corpus as provided by G.S. 17-39 is ousted and authority to provide for the custody of the children of the marriage vests in the court in which the divorce proceeding is pending. Robbins v. Robbins, ante, 430; In re Blake, supra; McEachern v. McEachern, supra; In re Albertson, supra; Tyner v. Tyner, 206 N. C. 776, 175 S. E. 144; Story v. Story, 221 N. C. 114, 19 S. E. (2) 136. Jurisdiction rests in this court so long as the action is pending and it is pending for this purpose until the death of one of the parties.
When, however, the parents were divorced outside this State, either parent may have the question of custody as between them determined in a special proceeding in the Superior Court. G.S. 50-13.
In all other instances in which the custody of an infant less than sixteen years of age is the subject of the controversy, the juvenile branch of the Superior Court of the county where the child resides or is to be found has exclusive original jurisdiction. G.S. 110-21 (3); In re Thompson, 228 N. C. 74. That is to say, the juvenile branch of the Superior Court has exclusive original jurisdiction in all cases wherein the custody of an infant under sixteen years of age is the subject of the controversy except (1) in cases between undivorced parents living in a state of separation, G.S. 17-39, or (2) where there is an action for divorce, in which a complaint has been filed, pending in this State, G.S. 50-13, or (3) where the parents have been divorced by decree of a court of a State other than North Carolina, G.S. 50-13.
It is to be noted that the exceptions include only cases in which the controversy is between the parents of the infant. In such cases the family relations are involved and each party has some natural as well as legal claim to the child. The child itself is under the protective custody of the court which exercises its sound discretion in providing for its welfare. For these reasons, perhaps, the Legislature, in adopting General Statutes, Chap. 110, Art. 2, saw fit to leave G.S. 17-39 and G.S. 50-13 unimpaired so that the authority to exercise this discretion would remain in the Superior Court judge rather than be vested in an inferior judicial official. In any event, we have so construed the statutes.
*633It follows that the court below correctly concluded that it was without jurisdiction to hear the matter either as upon a writ of habeas corpus or as a motion in the divorce action theretofore pending in Wilkes County.
The cases cited and relied on by petitioner are not in conflict with the conclusion here reached. In the TenHoopen case, 202 N. C. 223, 162 S. E. 619, the parents were living in a state of separation. While the writ, issued on the petition of the father, was directed to the maternal grandparents of the child, it was made to appear that the mother had possession of the child and the grandparents only had temporary custody as agents of the mother. Hence, in reality it was a contest between the parents living in a state of separation. So the Court held. In the Shelton case, 203 N. C. 75, 164 S. E. 332, the custody of an illegitimate child was at issue. The case was decided shortly after the adoption of the Juvenile Court Act and the question of jurisdiction was not mooted. But this Court, in the factually similar McGraw case, 228 N. C. 46, held that a writ of habeas corpus is not the proper medium for settling a controversy over the custody of a child as between its putative father and natural mother, In re Hamilton, 182 N. C. 44, 108 S. E. 385, is contra the contention of the petitioner.
The judgment entered in the court below was in accord with the decisions of this Court and is
Affirmed.