¶ 1 We are asked by Nathaniel and Christina O’Neal, parents of A.N.O., to determine whether the trial court exceeded its jurisdiction when it granted visitation rights to their child’s grandparents subsequent to the termination of the grandparents’ guardianship over her. The O’Neals additionally contend that if the visitation order is not void for lack of jurisdiction, it should nonetheless be reversed as it is an unconstitutional intrusion into their family life in violation of guarantees of the federal and state constitutions. We find that the trial court was without jurisdiction to issue the visitation order, and we vacate the opinion, of the Court of Appeals and reverse the judgment of the trial court.
¶2 In related eases the O’Neals brought appeals from orders in the same trial court action entered subsequent to the filing of this appeal. Case Number 99,340 concerns an order sustaining grandparents’ “Motion to Enforce” the previously entered visitation order that was the subject of this appeal, and Case Number 99,918 challenged the trial court’s award of attorney fees in the amount of $20,000.00 against parents for resisting the grandparents’ efforts to enforce the visitation order. Pursuant to Rule 1.27(d), Oklahoma Supreme Court Rules, 12 O.S.2001, Ch. 15, App. 1, we sua sponte consolidate these appeals under the earlier case number for disposition by a single opinion.1
¶ 3 We previously granted certiorari to the O’Neals, respondents/appellants, to consider the issue of the termination of the court’s jurisdiction over the subject matter of the guardianship which had been before it. The matter presents á question of law concerning the interpretation and application of statutes and is before us for de novo review.
¶ 4 The pertinent facts are these. When A.N.O. was five months old, her maternal grandparents, Floyd and Margaret Ogle, petitioners/appellees, filed a petition for guardianship of her person and estate as well as a petition seeking an emergency ex parte temporary order of guardianship based on conditions which they alleged placed A.N.O.’s physical and emotional welfare at risk of immediate harm. The trial court granted an *648emergency ex parte temporary order naming the Ogles the “temporary guardians” of A.N.O. The following month, the Ogles and the O’Neals appeared before the court and entered into an agreed order that named the Ogles “special guardians” of the person of A.N.O. until further order of the court, and the court issued them letters of “Special Guardianship.” The order also granted A.N.O.’s parents visitation rights and set out the terms for those visitation periods. A.N.O.’s mother and father were not married at the time of her birth on February 15, 1999; however, they were married by the time the guardianship ended.
¶ 5 In August, 2001, following five days of hearings with all parties present, the trial court determined that conditions had changed and A.N.O. should be returned to the custody of her mother and father. The order also granted .the O’Neal’s motion to terminate the Ogles’ special, or temporary, guardianship and denied the petition filed by the Ogles for guardianship which was still pending before the court. The order of the court provided: “the Court finds in favor of the Respondents and hereby denies the guardianship petition and orders the minor child returned to the Respondents ... The Petitioners’ Letters of Guardianship are hereby terminated and each is hereby discharged.”
¶ 6 The trial court encouraged the parties to enter into an agreeable visitation schedule for A.N.O.’s grandparents to see her. The parties could not agree and the court began in November.of 2001 a series of orders which compelled the O’Neals to allow visitation at specified times. The O’Neals had argued that the trial court was without jurisdiction over this issue, but the court asserted it had “continuing jurisdiction” over the issue of grandparental visitation rights with A.N.O. through the guardianship proceeding and under the provisions of 10 O.S. Supp.2000, § 5, the grandparental visitation statute. The court found § 5 gavé it the authority to impose orders for grandparents’ visits which it found to be in the child’s best interest, even if the parents objected.
¶ 7 On appeal, the O’Neals argued that when the trial court terminated the guardianship proceeding, returning the custody of their daughter to them and dismissing the guardians, its jurisdictional power and authority over their child and their family ended. They argued the court was therefore without lawful power to award visitation with A.N.O. to the Ogles, her former guardians, and that no statutory authority from any other source, including § 5, gave the court continuing jurisdiction to impose visitation against their wishes. The Ogles supported the position of the trial court and the Court of Civil Appeals upheld it. We agree with A.N.O.’s parents.
¶ 8 The procedures for the court’s appointment of a guardian and termination of that appointment are governed by the provisions of the Oklahoma Guardianship and Conservatorship Act, 30 O.S.2001, §§ 1-101, et seq., and relevant sections are set forth below. Section 1-113 concerns the appointment of a guardian and commencement of the court’s jurisdiction and provides in pertinent part:
A. A guardian of ... a person residing in this state, who is a minor ... may be appointed in all cases by the court as provided in this title.
B. After the service of notice in a proceeding seeking the appointment of a guardian or other order, in subsequent proceedings pertaining to the guardianship of a ward and until termination of the proceeding, the court in which the petition is filed has exclusive jurisdiction to determine:
1. the need for a guardian or other order ...
(Emphasis added.)
The powers of the court over the guardian are set forth in § 1-114, and the relevant portions provide:
A. In all cases the court making the appointment of a guardian has exclusive jurisdiction to control such guardian in the management and disposition of the person and property of the ward.
B. The court has jurisdiction over guardianship proceedings, and has the following powers, which must be exercised in the manner prescribed by statute, to:
*6491. appoint and remove guardians for minors ...
2. issue and revoke letters of guardianship;
The legal effect of letters of guardianship is established by § 1-123 as follows:
“Letters of guardianship are evidence of the transfer of the management or administration of all assets, or the part thereof specified in the letters, of a ward to the guardian. An order terminating a guardianship is evidence of transfer of the management or administration of all assets subject to the guardianship from the guardian to the ward.
The termination of a guardianship is controlled by § 4-804 which provides:
The guardian of [a] ... minor may be discharged by the court when it appears to the court, on the application of the ward or otherwise, that the guardianship is no longer necessary.
¶ 9 It is fundamental that jurisdiction is the authority by which courts take cognizance of and decide cases, and that the three elements necessary to the validity of a court order are jurisdiction of the person, jurisdiction of the subject matter and the power of the court to decide the particular matter and render the particular judgment at issue. Roth v. Union Nat. Bank of Bartlesville, 1916 OK 823, 160 P. 505. Subject matter jurisdiction is essential. It is the power and authority of a court to hear and determine causes of the kind in question. Thus, a court has the jurisdiction to try an action when it has jurisdiction of the persons and the cause is the kind of a cause triable in such court, and the power to render any rightful judgment therein. Board of Trustees of the Firemen’s Relief & Pension Fund v. Brooks, 1937 OK 245, 67 P.2d 4. Since subject matter jurisdiction concerns the competency of the court to determine the particular matter, it cannot be waived by the parties or conferred upon the court by their consent and it may be challenged at any time in the course of the proceedings. Shaffer v. Jeffery, 1996 OK 47, 915 P.2d 910. Subject matter jurisdiction is invoked by the pleadings filed with the court. State ex rel. Turpen v. A 1977 Chevrolet Pickup Truck, 1988 OK 38, 753 P.2d 1356. Where the pleadings state a case over which the jurisdiction of the court extends, jurisdiction attaches and the court has the power to hear and determine the issues involved. Flick v. Crouch, 1967 OK 131, 434 P.2d 256.
¶ 10 There is no question of the trial court’s jurisdiction to hear the' guardianship matter, to determine those issues and to enter the judgment terminating the guardianship, returning A.N.O. to the custody of her parents, and dismissing the grandparents’ pending guardianship petition. Jurisdiction was properly invoked by the pleadings, properly exercised by the court and properly concluded by the order. Pursuant to 30 O.S.2001, § 1-113 the trial court had jurisdiction over the guardianship “until termination of the proceeding.” That jurisdiction ended according to law with the finality of the court’s termination order, and the court had no power to order the O’Neals to submit to visitation against their wishes. 30 O.S.2001 § 4-804.
¶ 11 From the authority set forth above, outlining basic concepts of subject matter jurisdiction, the trial court’s finding that it had “continuing” jurisdiction over grandpa-rental visitation rights by reason of Title 10, O.S. § 5, is unsustainable. In pertinent part, the grandparental visitation statute provides:
A. 1. Pursuant to the provisions of this section, the grandparent of an unmarried minor child may seek and be granted reasonable visitation rights to the child which visitation rights may be independent of either parent if the district court deems it to be in the best interest of the child and
[[Image here]]
e. the grandparent had custody of the grandchild pursuant to Section 21.3 of this title, whether or not the grandparent had custody under a court order, and there exists a strong continuous grandparental relationship between the grandparent and the child,
[[Image here]]
i. At any other time and for such other reason the court deems it to be in the best interests of the child.
[[Image here]]
*650E.- The district courts are vested with jurisdiction to issue orders granting grand-parental visitation rights and enforce such visitation rights, upon filing of a verified application for such visitation rights or enforcement thereof. Notice as ordered by the court shall be given to the person or parent having custody of the child and the venue of such action shall be in the county of the residence of such person or parent. (Emphasis added.)
¶ 12 There was no action brought pursuant to the provisions of 10 O.S. § 5(E)(1) and the court was therefore not competent to pass on those statutory issues. The Ogles had neither filed a verified application nor given notice as required by the statute. The subject matter jurisdiction of the court had been not invoked by proper pleadings to hear and determine a cause under § 5, and the trial court had no jurisdiction under that statute of either the subject matter or the parties to hear the cause pm-ported to be subject to those provisions. These efforts by grandparents to obtain visitation should have been dismissed by the trial court for lack of subject matter jurisdiction.
¶ 13 The O’Neals also argue that the trial court’s order imposing visitation violated their constitutional rights. In support of their position, they cite In re Herbst, 1998 OK 100, 971 P.2d 395 and Neal v. Lee, 2000 OK 90, 14 P.3d 547. In Herbst, a grandfather sought to visit his grandchild against the wishes of the parents. He relied on 10 O.S.Supp.1996 Section 5(A)(1), an earlier version of the statute before us, asserting visitation was in the child’s best interest. This Court held the statute to be an unconstitutional intrusion into family life, as it required no threshold showing of harm or threat of harm before bringing the issue of a child’s best interests within the province of the court. In Neal v. Lee, supra, this Court followed the teaching of Herbst, and terminated grandparental visitation rights that were granted under 10 O.S. § 5 without a showing that the children would suffer harm without court ordered visitation. Our holding in Neal relied in part, as do the O’Neals, on Troxel v. Granville, 530 U.S. 57, 120 S.Ct. 2054, 147 L.Ed.2d 49(2000), where the United States Supreme Court addressed the issue of court-ordered grandparental visitation and held that the Fourteenth Amendment protects a parent’s right to raise her child without undue governmental interference and that a fit parent is accorded a presumption that she acts in the child’s best interest.
¶ 14 Since we view the matter of subject matter jurisdiction determinative of this appeal, we find it unnecessary to decide the O’Neals’ due process challenges to § 5 and the trial court’s order of visitation. “Courts, of course, will pass upon the constitutionality of a statute only when it is necessary to a determination on the merits.” Schwartz v. Diehl, 1997 OK 115, 568 P.2d 280, 283.
¶ 15 The l-ulings of the trial court in the consolidated cases must also be reversed as they were, likewise rendered without jurisdiction. In light of this resolution of these appeals we find it unnecessary to address the merits of the arguments presented by the parties in those matters.
¶ 16 THE OPINION OF THE COURT OF APPEALS IN 97,980 IS VACATED AND THE JUDGMENT OF THE TRIAL COURT IS REVERSED; IN THE APPEALS CONSOLIDATED FOR DECISION, 99,340 AND 99,918, THE JUDGMENTS ARE REVERSED.
¶ 17 WATT, C. J., HODGES, LAVENDER, HARGRAVE, KAUGER, BOUDREAU, WINCHESTER, JJ., concur. ¶ 18 OPALA, V.C.J., dissents.. The pertinent provisions of the Rule state:
(d) Consolidated and Companion Appeals.
[[Image here]]
The appellate court has the discretion sua sponte, or upon motion of a party, to consider any appeals including one or more appeals governed by Rule 1.36 as companion or consolidated appeals.