delivered the opinion of the-court.
In this case Julio Aguilera alleged that ha had acquired a homestead on a frame house, built upon a lot belonging to-the Municipality of Gruánica. The defendants, Ramón Pérez Ijugo- and Antonio Antonmattei, in their answer to the-complaint set up the following defense:
“That the present action of the plaintiff does not lie, as the same is res adjudicata and a matter which has been finally determined, because this same action was prosecuted by the same plaintiff herein, Julio Aguilera, before this court, in civil case No. 2958, against defendant Ramón Pérez Lugo, upon the same facts set out *2in bis present complaint, and judgment thereon was rendered by this court on January 26, 1931, dismissing the complaint, from which judgment the plaintiff appealed to the District Court of Ponce on February 5, 1931, and on May 7, 1931, the said District Court of Ponce dismissed the appeal brought, ease No. 5696, such decision becoming final (firme) and enforceable, since no appeal from it was taken by the plaintiff Julio Aguilera to the Supreme Court of Puerto Rico... An.d, as between the two eases there is identity with Respect to the parties plaintiff and defendant and the cause of action and claim, the action now prosecuted is subject to the defense of res adjudicata, in accordance with section 1219 of the Civil Code in force.”
The lower court overruled the foregoing- defense set up by the defendants, and rendered judgment for the plaintiff. The appellants maintain that that court erred in overruling their special defense of res judficata, and ask that the judgment appealed from be reversed.
■ [1, 2] It appears from the record, and it is so stated by the lower court in its findings, that in December 1929, Ramón Pérez Lugo, defendant herein, brought, in the Municipal Court of Yauco, an action of debt against Julio Aguilera and obtained judgment in his favor. In order to secure said judgment an attachment was levied on the house of Julio Aguilera described in the present complaint. Aguilera then filed, in the Municipal Court of Yauco-, a complaint alleging a homestead right on said piece of property. This complaint was demurred to on the ground thajt it did not state facts sufficient to constitute a cause of action. After the demurrer had been sustained and judgment rendered against the plaintiff, the latter appealed to the District Court of Ponce, which dismissed the appeal because of the failure to serve appellee Pérez Lugo with notice of the appeal, and the said judgment became final (firme).
The municipal court in overruling the demurrer and rendering judgment against the plaintiff, failed to- grant leave to amend the complaint. The objection had been raised by a general demurrer, without the defendant specifying the *3grounds on which he based his claim that the pleading did not state a cause of action. The ruling of the court, entered also in general terms, failed to. set forth the grounds on which the court relied for sustaining the demurrer and rendering judgment for the defendant.
The facts alleged by the defendants in their, special defense have been satisfactorily proved by documentary evidence. On this point there is no controversy between the parties; but it is urged by the plaintiff that such facts, thus alleged and proved, do not constitute a proper basis for sustaining the defense of res judicata.
A judgment upon the sustaining of a demurrer is conclusive of the facts confessed by the demurrer as a verdict or judgment finding the same facts, alleged in the complaint ■Would have been.
Therefore, where the demurrer goes to the merits of the cause of action any judgment rendered on such demurrer may be successfully pleaded in a litigation between the same parties and upon the same cause of action. A judgment, however, can not operate as res judicata when questions purely of form are involved and not all the merits of the case have been determined by the demurrer.
As a general rule a judgment rendered upon a general demurrer finally concludes the case upon its merits. Perkins v. Moore, 16 Ala. 17; Brown v. Kirkbridge, 19 Kan. 588; Weatherford v. Nuveen, 211 Ill. App. 411; Pettis v. McLain, 21 Okla. 521, 98 Pac. 927.; El Reno v. Cleveland-Trinidad Paving Co., 25 Okla. 648, 27 L.R.A. (N.S.) 650, 107 Pac. 163. The reason for this rule is that a general demurrer admits as true all the facts alleged in the complaint, and that therefore a final judgment sustaining it is as conclusive of those facts as if the plaintiff had proved them and obtained a judgment in his favor. Bomar v. Parker, 68 Tex. 435, 4 S.W. 599. Not eyery general demurrer, however, goes to the merits of the cause of action. F.or instance, those based *4on the want of jurisdiction, although generally aimed at the action as a whole, do not challenge in any form the legal sufficiency of the facts alleged in the complaint. Any judgment under such circumstances, sustaining the demurrer of the defendant for want of jurisdiction is not a decision upon the merits of the case.
A demurrer to the complaint on the ground that it does not state facts sufficient to constitute a cause of action goes to the merits of the cause of action, as ft challenges the legal sufficiency of the facts stated in the complaint, and thus raises an issue, which, when tried, will finally dispose of the case on its merits, unless leave to amend the complaint is granted. Alley v. Nott, 111 U. S. 472, 28 L. Ed. 491; Parrotte v. Dryden, 73 Neb. 291, 102 N.W. 610; Hirshbach v. Ketchum, 80 N.Y. Supp. 143; Moore v. Chattanooga Elec. R. Co., 119 Ten. 710, 16 L.R.A. (N.S.) 978, 109 S.W. 497; Plant v. Carpenter, 19 Wash. 621, 53 P. 1107.
In Bissel v. Spring Valley Township, 124 U. S. 225, 233, the following is transcribed from the Treatise on Procedure by Gould:
■ “A judgment, rendered upon demurrer, is equally conclusive (by way of estoppel) of the facts confessed by the demurrer, as a verdict finding the same facts would have been; since they are established, as well in the former case as in the latter, by way of record. And facts, thus established, can never afterwards be contested, between the same parties, or those in privity with them. Chap. IX, part 1, sec. 43.”
In Parrotte v. Dryden, 102 N.W. 610, the Supreme Court of Nebraska expressed itself as follows:
“A demurrer to a complaint because it does not state facts sufficient to constitute a cause of action is equivalent to a general demurrer to a declaration at common law, and raises an issue which, when tried, will finally dispose of the case as stated in the complaint on its,merits, unless leave to amend or plead over is granted. The trial of such an issue is the trial of the cause, and not the settlement of a mere form in proceeding. There can be no other trial except at the discretion of the court, and, if final judgment is entered *5on the demurrer it will be a final determination of the rights of the parties, which can be pleaded in bar to any other suit for the same cause of action. (Citations.)”
The foregoing extract was literally copied by the Supreme Court of Nebraska from the decision rendered by the Supreme Court of the United States in Alley v. Nott, 111 U.S. 472, 475.
In Sudderth v. Harris, 181 S.E. 123, a case decided in 1935, the Court of Appeals of Georgia, Second Division, expressed itself as follows;
“A judgment sustaining a general demurrer to a petition, on the ground that the petition sets out no cause of action, is a decision upon the merits of the case. The judgment is res judicata of the cause of action sued on. (Citations.)”
In Hart Steel Co. v. Railroad Supply Co., 244 U. S. 294, 299, the Supreme Court of the United States said:
“This doctrine of res judicata is not a mere matter of practice or procedure inherited from a more technical time than ours. It is a rule of fundamental and substantial justice, £of public policy and of private peace,’ which should be cordially regarded and enforced by the courts to the end that rights once established by the final judgment of a court of competent jurisdiction shall be recognized by those who are bound by it in every way, wherever the judgment is entitled to respect. Kessler v. Eldred, 206 U.S. 285.”
In Wade v. Peters, 13 A.L.R. 1100, the Supreme Court of Oregon laid down the doctrine that a judgment sustaining a demurred and dismissing the complaint on the ground that the same does not state facts sufficient to constitute a cause of action, becomes, unless reversed, a final determination of the questions set forth in the complaint and may be alleged in bar to a subsequent suit upon the same cause of action. It was further stated by that court, citing the case of O’Hara v. Parker, 27 Or. 156, 39 P. 1004, that where an essential allegation has been omitted from a complaint to which a demurrer is interposed, a judgment of dismissal is no bar to a second suit between the same parties if the omit*6ted!: essential fact is alleged in the second suit. .After discussing this question the court said:'
, ‘ ‘ This concise statement of the law is clear and accurate, and is confirmed by our own investigation of the authorities. It is of no' .avail to the plaintiff in the present action, however, since a careful examination of the complaint in the prior action discloses that no essential allegation is omitted therefrom, and the later pleading contains no substantial averment which is not found in the former. This being true, it follows .that plaintiff’s only effect tiv'e recourse in the first action was to have appealed from the judgment upon the demurrer, and, having failed to do so, he is barred from prosecuting the present proceeding.”
See also the note appearing ait the foot of the case just cited.
The same doctrine. has been upheld in California. In Dyment v. Board of Medical Examiners, 268 Pac. 1073, the following appears:
“By California authorities (15 Cal. Jur. 127), the law appears to be settled that, while a judgment upon the sustaining of a demurrer to the complaint for failure to state a cause of action is a bar to a subsequent action setting up the same facts,'that effect is not produced if in the second case an essential fact, missing in the first case, be supplied.”-
This is a rule firmly established by the decisions of the courts. A judgment sustaining a demurrer for want of facts sufficient tó constitute a cause of action does not support the defense of res judicata as ag’ainst a complaint in which a defect has been cured by supplying ah essential allegation omitted from a former complaint.
It has been established by the decisions that where the court rendering a judgment has jurisdiction, error in the judgment does not prevent it from becoming a bar to a second action. A judgment does not lose its effectiveness as res judicata from the mera fact thaJt it is irregular oi erroneous. Clemens v. Kansas Gas & E. Co., 69 A.L.R. 999, and note thereto.
*7In Calaf et al v. Calaf, 17 P.R.R. 185, a demurrer was interposed to the complaint on the grounds that the plaintiffs lacked capacity to sne, that the complaint did not state facts sufficient to constitute a cause of action, that the pleading was ambiguous, and that the action for the acknowledgment of a natural child prosecuted by the plaintiffs had prescribed. The lower court sustained the demurrer. An appeal was taken to this court, which held that the acknowledgment of a natural child having been denied in a former judgment, such decision could not be challenged or questioned in a subsequent action.
The above case was affirmed by the Supreme Court of the United States in Calaf v. Calaf, 232 U.S. 371. In upholding the plea of res judicata, the Court said:
"The Supreme Court of Porto Rico has applied the principle here and we should require the clearest authority before we overruled an application that seems to us so obviously correct. It is urged further that there was no final judgment in the former case. Upon a question of that sort we follow the local court unless stronger reasons against it are produced than can be shown here."
Such was our decision in that case, in which the above-mentioned defenses were set up. There arei courts which-hold that wherq a demurrer is directed against formal defects and the merits of the ease, a judgment which fails to specify the grounds upon which the decision is based shall be presumed to rest on the former. Bissell v. Spring Valley Township, supra; Motes v. Gila Valley G. & N. Ry. Co., 11 Ariz. 39, 89 Pac. 410; Griffin v. Seymour, 15 Iowa 30, 83 Am. Dec. 396; Goldsborough v. Hewitt, 23 Okla. 66, 128 Am. St. Rep. 795, 99 P. 907. Other courts hold a contrary doctrine, that is, that a judgment or decree upon a demurrer going both to the merits of the case and to matters of form therein operates as res judicata. State ex rel. Schmidt v. Superior Ct., 62 Wash. 556, 114 Pac. 427; Schroers v. Fisk, 10 Colo. 599, 16 Pac. 285; Merrill v. Board of Com’rs of Ness County, 7 Kan. App. 717, 52 Pac. 109.
*8In the ease at bar a demurrer' was interposed to the first complaint on the ground that it did not state facts sufficient to constitute a cause of action. This was the only demurrer interposed, and no defect of form was urged by the then defendant. We have carefully read both the complaint filed in the Municipal Court of Tauco and the one filed by the plaintiff: in the instant case, and we have reached the conclusion that no fact essential to the cause of action is contained in the complaint filed in the latter suit which is not found in the complaint filed in the former action. Both complaints are substantially identical. For these reasons we hold that the District Court of Ponce erred in declaring that the said judgment was no bar to the prosecution of the present action.
The judgment appealed from must be reversed and the complaint dismissed, without special imposition of costs.
Mr. Chief Justice Del Toro took no part in the decision of this case.