delivered the opinion of the Court.
On November 15, 1948, Virginia Tranum Pereyó filed a complaint of “unlawful detainer at sufferance” in the District Court of San Juan against Gerardo Pérez. She alleged that she was the owner of an urban property situated in Santurce which is described in the complaint; that prior to her having *626purchased said property it had been leased by its former owner to Aníbal Ruiz Virella and René de la Cruz, who in turn had subleased part of the first floor to defendant Gerardo Pérez, by an oral month-to-month lease; that on October 1, 1948, she and the lessees Ruiz and De la Cruz considered the lease terminated 1 and that she never accepted nor consented, either impliedly or expressly, to the sublease between the latter and the defendant; that on October 21, 1948 she notified the defendant in writing that since the lease of Ruiz and De la Cruz had ceased, defendant’s right to occupy the premises had likewise ceased and she requested him to vacate the premises on October 31 at the latest, which defendant has refused to do; and that the latter occupies said premises for his barber shop precariously,2 without any contract or right whatsoever and against plaintiff’s will.
The defendant was summoned and he set up a demurrer that the complaint did not state a cause of action. He answered and accepted the facts of the complaint but denied the allegation that plaintiff had never accepted nor consented, impliedly or expressly, to the sublease or that he occupied the premises precariously. He also alleged as special defense that he occupied the premises under a contract of lease with Aníbal Ruiz Virella and René de la Cruz; that the plaintiff knew of said sublease and that she never raised any objections, thereby consenting tacitly to the sublease.
This being so, on November 29, 1948, a stipulation was filed in the District Court of San Juan by the parties as well as by their counsel. In it the defendant admitted the facts alleged in the complaint and consented to a judgment for plaintiff ordering defendant to surrender and vacate the premises which he occupied “within a term of six months beginning to run December 10, 1948”; and that the defend*627ant should continue to pay, as a just and reasonable compensation for the use of the premises during said period, the same amount he had been paying as rent. It prayed the court to render judgment in accordance with the terms of the stipulation and that the judgment be unappealable from the date it was rendered.
On April 7 of the same year the lower court rendered judgment in accordance with the stipulation. However, on May 4 the defendant, represented by a different attorney, filed in the same court a “Motion to set aside stipulation and judgment and for stay of proceedings”. In that motion, after summing up the facts stated in this opinion, he alleged, among, other things, that the purpose of the complaint, although it does not appear from the. pleadings, was to evict the defendant in order to enlarge the business of plaintiff’s mother, which is adjacent to defendant’s barber shop; that the stipulation contained no consideration and that it was accepted by him lest he be evicted within a short period; that the plaintiff did not comply with the provisions of subdivision 1(e) of § 12Á of the Reasonable Rents Act, since she did not serve him with an authentic written notice that she needed the premises for her own occupancy and that she did not ask him to vacate it at least six months in advance to the filing of the complaint; that the court acted without jurisdiction in rendering judgment by stipulation which was contrary to law; and that the plaintiff knew that he occupied the premises in question under a lease he had with Ruiz and de la Cruz. The motion was heard and plaintiff opposed it in writing. After hearing the parties the lower court issued an order dismissing it. We issued the writ of certiorari to review that order.
Plaintiff’s first contention to oppose defendant’s motion as well as the writ of certiorari is that the judgment rendered by the same court on April 7, 1948 is res judicata. We agree. The judgment rendered by the stipulation sub*628mitted by the parties has the same scope and force as a judgment rendered on the merits of a case. Such a judgment by stipulation cannot be attacked collaterally unless it is rendered without jurisdiction over the parties or the subject matter. Suárez v. Betancourt, 64 P.R.R. 447; Valdés v. Hastrup, 64 P.R.R. 569; Ex parte Morales, 17 P.R.R. 1004; Stoll v. Gottlieb, 305 U. S. 165, 176; Swift & Co. v. United States, 276 U. S. 311, 72 L. ed. 587; Walling v. Miller, 138 Fed. 2d 629; Malone v. Meres, 109 So. 677; Freeman on Judgments, vol. 3, 5th edition, § 1350, p. 2773; 49 C.J.S. § 178, p. 317; 31 Am. Jur., §§ 576 and 583, pp. 175 and 181.
With this principle in mind, we turn to consider whether in the instant case the court had jurisdiction over the parties and over the subject matter and whether the attack on the judgment is direct or collateral.. As to the question of jurisdiction over the parties it is unquestionable that the lower court had jurisdiction. The plaintiff went to said court and submitted to its jurisdiction. The defendant was duly summoned, appeared by brief, demurred to the complaint, answered and subsequently consented to the aforesaid stipulation. Accordingly, the lower court acquired jurisdiction over his person. Subdivisions 2 and 3 of § 77 of the Code of Civil Procedure. As to whether the lower court had jurisdiction over the subject matter it is likewise unquestionable that it did. This is not precisely a question of an unlawful detainer at sufferance but rather of an unlawful detainer for wrongful occupancy3 where, notwithstanding the existence of a sublease, the whole property is sold to plaintiff herein and she and the lessees of the former owner rescind the previous contract of lease and the new owner alleges never to have accepted the sublease. All this is accepted by the defendant in the stipulation. In purchasing, the plaintiff was entitled to file an unlawful detainer in the district court against the defendant because she did not ac*629cept any contract between them. Section 1461 of the Civil Code, 1930 ed.; Carrasquillo v. Ripoll and Montalvo ,56 P.R.R. 301; § 3, paragraph 2 of Unlawful Detainer Act, § 622 of the Code of Civil Procedure, 1933 ed.
In addition, such an action does not fall within the purview of any of the modalities listed in § 12A of Act No. 464 of April 25, 1946, p. 1326, known as the Reasonable Rents Act, as this Section was amended by Act No. 201 of May 14, 1948, p. 574. Since the action of unlawful detainer is not contemplated by any of the provisions of $ 12A supra, we must look to § 12B of said Act, as amended by Act No. 24 of August 21, 1948, p. 238, which essentially provides:
“In any other case in which unlawful detainer proceedings may be prosecuted under insular or federal legislation, the plaintiff may not file his action until after he has served on the tenant not less than six months in advance of the date of the filing of said unlawful detainer action, authentic written notice of his intention to recover the property.
“The court shall, in all actions in which the aforesaid requisite notice has not been given, order the stay of the proceedings until the term of said notice has elapsed.” (Italics ours.)
The action filed by Virginia Tranum is fully contemplated by the provisions of § 12B copied above. The complaint in this case, as we have indicated, was filed on November 15, 1948 and it was specifically alleged therein that plaintiff had notified defendant on October 21 of that year.' It is clear from the face of the complaint that at the time of its filing the six-month period allowed by § 12B had not yet elapsed, counted from the day notice was served on defendant. The statute does not say, however, that in cases of this sort when the complaint is filed prior to the expiration of said period the court shall lack jurisdiction over the action. But it does say that the proceedings shall be suspended until the lapse of the six-month period. This plainly shows that the court has jurisdiction to entertain the case for otherwise it could not stay the proceedings but merely declare itself without jur*630isdiction. López v. District Court, 68 P.R.R. 291. Furthermore, as a matter of fact, in this case the statutory period of six months expired inasmuch as the defendant was notified by the plaintiff on October 21, 1948, that she intended to recover the property and the lower court did not render judgment until the following April 7, to take effect on June 10, 1949. Therefore, we have no doubt that the court had jurisdiction to render judgment as it did.
Having decided that the court had jurisdiction over the parties as well as over the subject matter we turn to determine whether the attack made by the defendant on the judgment was direct or collateral. According to the weight of authority and the textwriters a direct attack on a judgment is that which is made in the same action by any other proceeding provided by law, as for example by appeal, motion for a new trial or motion for a rehearing, provided, of course, that the attack is made within the period fixed by law. 49 C.J.S. § 408, p. 805. If the attack on a judgment is made in any other manner, whether in an independent proceeding, before another court or after the expiration of the time allowed by statute, it is a purely collateral attack. Freeman on Judgments, vol. 1, 5th ed., §§ 277 and 306, pp. 547 and 604. In the instant case the attack on the judgment was made in the same court and in the same proceeding, but when the judgment was already final and unappealable not only in accordance with the terms of the stipulation but also because, even in the absence of such showing, the 5-day period granted by law to appeal in a case of this nature had already expired, as well as the terms to file a motion for a new trial or for a rehearing. Sections 220 and 292 of the Code of Civil Procedure.
Since the court has jurisdiction over the subject matter and the parties and the attack made by the defendant is collateral, the judgment rendered in the case is res judicata. The- lower court acted correctly ih so deciding.
*631The case of Cintrón v. Municipal Court, 67 P.R.R. 743, cited by the parties may be distinguished. Although it is true that a judgment by stipulation in an unlawful'detainer proceeding was rendered therein, prior to its execution the Legislature. approved an Act staying all the proceedings of unlawful detainer which did not comply with the conditions or terms provided therein. We decided in that case that by virtue of said Act if the proceedings were not yet closed, the judgment rendered should be stayed. In this case, however, there is no subsequent law which may affect the rights of the parties.
In view of the foregoing considerations we find it unnecessary to pass on the other questions raised by the petitioner.
The writ issued will be quashed.