In 1954, E. A. Moore, Jr., and Lavena S. Moore, husband and wife, hereinafter designated as the Moores, delivered a note secured by a first mortgage on the property in question to Farmers New World Life Insurance Company, hereinafter designated Farmers. In 1957, Robert Rousselle and Rachel L. Rousselle, husband and wife, hereinafter designated as the Rousselles, purchased the property, giving the Moores a promissory note and a second mortgage. The Moores assigned this note and mortgage to Omega Construction Company, hereinafter designated Omega, in 1958. The Rousselles then sold the property to Myra L. McDonell, who agreed to be liable as assignee on the note and the second mortgage that the Rousselles had originally given to the Moores. Myra L. McDonell also gave her own promissory note and a third mortgage to the Rousselles. On July 22, 1959, Omega brought suit (Cause No. 109016, Superior Court of Maricopa County, State of Arizona) on the second mortgage and attached promissory note due to an alleged default of the July 1, 1959 payment due under this note.
By an uncontradicted affidavit in the instant case, after negotiations between the parties in this July 1959 action, Omega agreed to move for a dismissal against itself if the court would assign all the back payments which it held in its custody to Omega. In accordance with this agreement, on March 18, 1960, the superior court made an order dismissing Omega’s complaint and ordering that the funds then held by the court be paid to Omega. This dismissal was with prejudice, and by uncontradicted affidavit it is explained that the reason the requested order was with prejudice is that Myra L. McDonell wanted to escape any liability for acceleration of the note payments due to the late payment in July 1959.
On May 2, 1960, the note with the same second mortgage attached was assigned to Roy Jewett. On September 1, 1960, there was another default in the payments due under this note, and on September 15, 1960, there was a default on the note held by Farmers to which the first mortgage was attached. Farmers brought a suit against *512defendants the Moores, the Rousselles, Myra L. McDonell, Omega, Roy Jewett, and others, to foreclose any interest of defendants in the mortgaged property. Jewett answered Farmers complaint; and filed a cross-claim against Myra L. McDonell, the Rousselles, and others, on February 15, 1961, because of the alleged defaults under the note attached to the second mortgage. Farmers recovered a judgment in May 1961, and Myra L. McDonell and the Rousselles answered Jewett’s cross-claim the following month. Both Jewett and the Rousselles moved for a summary judgment on the cross-claim, and Jewett filed affidavits in accordance with his motion. The superior court granted Jewett’s motion for summary judgment, and, on March 20, 1963, entered a final judgment in accordance with this motion. The Rousselles appeal from the summary judgment alleging a sole assignment of error that the previous motion to dismiss with prejudice granted by the superior court against Omega was res judicata of the action in the instant case.
The complaint of Omega in Cause No. 109016 based its action on Myra L. Mc-Donell’s failure to pay the note payment due in July 1959. The cross-claim in the instant case is based on a default in payments since October 7, 1960 (payment on that date was for the payment due September 1, 1960). The Rousselles submitted no affidavits in the instant case, and in their memoranda merely rely on the proposition that the motion to dismiss with prejudice in Cause No. 109016 precludes any further liability under the note in question. To facilitate discussion we can just as easily treat the motion to dismiss with prejudice' in Cause No. 109016 as any other judgment, and ignore the fact that it was arrived at by a stipulation of the parties in that action.
The Rousselles rely entirely on the proposition that a final judgment is res judicata as to all issues that were raised or could have been raised under the pleadings of the former action. They point out that in Cause No. 109016 the right to acceleration under this note was pleaded and contested, and that the order in that action was against Omega with whom Jewett is in privity and thus precludes Jewett from bringing this action for acceleration of payments and foreclosure of the attached mortgage. For a prior suit to be res judicata, the same issues must be decided therein which were raised in the second cause. Only such matters are adjudicated in a former judgment which appear upon its face to have been adjudicated or which were actually and necessarily included therein or necessary thereto. Rights, claims, or demands — even though they grow out of the same subject matter- — which constitute separate or distinct causes of action not appearing in the former litigation, are not barred in the latter action because of res judicata. Daugherty v. Board of Trustees, 111 Cal.App.2d 519, 244 P.2d 950; Title Guarantee & Trust Co. v. Monson, 11 Cal.2d 621, 631, 81 P.2d 944; and Wagner v. Savage, 195 Or. 128, 244 P.2d 161. All that could have been litigated in Cause No. 109016 was that the July 1959 payment was not in default, and that defendants in that action were not liable for past-due installments, nor were they liable for any acceleration under the note for the alleged July 1959 default in payment. This is in no way res judicata of the action brought under Jewett’s cross-claim. The cross-claim predicates defendants’ liability on their failure to make payments from September 1960, and it is impossible to see how the issue of defendants’ liability alleged in the cross-claim “could have been litigated” in an action which terminated over six months prior to the breach upon which this action is based.
In Lakin Cattle Co. v. Engelthaler, 101 Ariz. 282, 419 P.2d 66, we stated that in accordance with 16 A.R.S., Rules of Civil Procedure, Rule 8(d) res judicata is an affirmative defense which must be both pleaded and proved by the party relying on this defense. In the instant case, the Rousselles pleaded Cause No. 109016, but did not attempt to prove that it was res *513judicata of the instant action. They merely relied on the prior action, as it appeared on its face. In the Lakin case, we held that because defendants’ liability — based on a certain payment — was once litigated in defendants’ favor, did not necessarily mean that the prior action was res judicata of a later action which was based upon a failure to pay this same payment, because of the possibility of intervening material facts which could inject a new issue in the case. The relevant test is not whether there has been a prior lawsuit, but whether the same cause of action, or one so closely related that its proof depends on the same facts, has once been litigated. Lawler v. National Screen Service Corp., 349 U.S. 322, 75 S.Ct. 865, 99 L.Ed. 1122; National Ro-Tile Corporation v. Loomis, 82 Idaho 65, 350 P.2d 217; Williams v. Williams, 32 Ariz. 164, 256 P. 356; 30A American Jurisprudence, Judgments, Sec. 365.
The first cause of action was for default in the payment for the month of July 1959. The acceleration claim in those pleadings was based upon non-payment of the July 1959 payment. While the litigation was pending, McDonell paid her monthly installments into court, and in March of 1960 Omega agreed to move to dismiss its action in return for back-payment funds held by the court. The parties continued the monthly payments for approximately six months after the dismissal of the first case. In the instant case, the issues were whether there was a default in the monthly payments of September 1960 and all following payments, and the mortgagee-promisee’s rights growing out of these non-payments; while in the first case the issue was the rights growing out of non-payment of the July 1959 payment — namely the acceleration- — and it is not in any way involved in the present suit for a default in payments beginning in September of 1960. The claim therefore is not the same as that involved in the first case.
In Lakin Cattle Co. v. Engelthaler, supra, we said:
“ * * * For the court below to grant a judgment based on a motion to dismiss because of res judicata, the record must show appellant had already had its day in court under the facts and circumstances as they existed at the time the dismissed complaint was filed. * * * ” 101 Ariz. at 285, 419 P.2d at 69
The same reasoning applies whether it is a motion to dismiss, a summary judgment, or any other determination which is based upon a finding of res judicata. The record must show that the prior judgment was based upon a determination of certain facts and circumstances which would be re-litigated and govern the outcome of the present litigation. Neither Jewett nor those with whom he may be in privity had ever had their day in court as to the issues and liabilities concerning default for September 1960 and subsequent months. The record here clearly shows that the facts giving rise to the first claim were clearly separate and distinct from those in the instant case.
The prior case was decided upon facts and circumstances surrounding an alleged breach in July of 1959, while the claim in the instant case is predicated on alleged breaches beginning in September 1960. In the Lakin case, supra, res judicata was a possibility that was not proven. In the instant case, res judicata is an impossibility. A final determination of an action concerning one breach does not preclude a later action based upon a breach allegedly occurring after the judgment in the prior action. Pinkerton v. Pritchard, 71 Ariz. 117, 223 P.2d 933.
STRUCKMEYER, C. J., BERNSTEIN, V. C. J., and UDALL and LOCKWOOD, JJ., concur.