Justice Florenz D. Regalado explicates subject matter jurisdiction:
16. Basic … is the doctrine that the jurisdiction of a court over the subject-matter of an action is conferred only by the Constitution or the law and that the Rules of Court yield to substantive law, in this case, the Judiciary Act and B.P. Blg. 129, both as amended, and of which jurisdiction is only a part. Jurisdiction … cannot be acquired through, or waived, enlarged or diminished by, any act or omission of the parties; neither can it be conferred by the acquiescence of the court…. Jurisdiction must exist as a matter of law…. Consequently, questions of jurisdiction may be raised for the first time on appeal even if such issue was not raised in the lower court….
17. Nevertheless, in some case, the principle of estoppel by laches has been availed … to bar attacks on jurisdiction….[69]
It is, therefore, clear that jurisdiction over the subject matter is conferred by law. In turn, the question on whether a given suit comes within the pale of a statutory conferment is determined by the allegations in the complaint, regardless of whether or not the plaintiff will be entitled at the end to recover upon all or some of the claims asserted therein.[70] We said as much in Magay v. Estiandan:[71]
[J]urisdiction over the subject matter is determined by the allegations of the complaint, irrespective of whether or not the plaintiff is entitled to recover upon all or some of the claims asserted therein-a matter that can be resolved only after and as a result of the trial. Nor may the jurisdiction of the court be made to depend upon the defenses set up in the answer or upon the motion to dismiss, for, were we to be governed by such rule, the question of jurisdiction could depend almost entirely upon the defendant.
Of the same tenor was what the Court wrote in Allied Domecq Philippines, Inc. v. Villon:[72]
Jurisdiction over the subject matter is the power to hear and determine the general class to which the proceedings in question belong. Jurisdiction over the subject matter is conferred by law and not by the consent or acquiescence of any or all of the parties or by erroneous belief of the court that it exists. Basic is the rule that jurisdiction over the subject matter is determined by the cause or causes of action as alleged in the complaint.
x x x./"