Opinion
This is an appeal by lessees Lowell A. Wooden and Dorothy M. Wooden, appellants, from a judgment in favor of lessor J. W. Greenhut, respondent, in an unlawful detainer action. Because of the complex nature of the transactions involving their occupancy of the residential property in question, appellants maintain that they should have been allowed to try the issue of title in the unlawful detainer action. Although it is rare that title can be tried in such an action, there are a few exceptions. Inasmúch as we have one of the exceptions here, we must reverse.
*66Respondent is the owner of record of certain residential property located at One Appoloosa Lane in the City of Rolling Hills, California. Appellants desired to purchase this property and also sought additional options on three lots owned by respondent that surrounded the Appoloosa Lane property. In November 1978 two documents were executed by respondent and appellants. The first document was a lease agreement in which respondent rented the above property to appellants for an 18-month period commencing November 1, 1978, and terminating May 31, 1980. In consideration for the leasehold appellants were to make payments of $3,000 per month and were required to make a minimum of $50,0001 worth of improvements to the property.
The second document was an option agreement purporting to give appellants the exclusive right to purchase the Appoloosa Lane property up until May 31, 1980. Apparently the consideration for the option was the improvements to be made by appellants as set forth in the lease agreement. The option also required appellants to cooperate with respondent in effecting a tax-deferred exchange pursuant to Internal Revenue Code section 1031. Additional options were similarly executed for the three lots surrounding the residential lot. Appellants took possession of the Appoloosa Lane property and commenced work on the improvements.
On June 28, 1979, appellants sent respondent notices that they were exercising the options to purchase the Appoloosa Lane property and the surrounding lots. Respondent disaffirmed the option and shortly thereafter filed in the superior court action No. C-279898 seeking declaratory relief, rescission, conversion, and quiet title, to the Appoloosa Lane property. Appellants then initiated action SWC51914 seeking quiet title, breach of contract, intentional interference with contract, unjust enrichment and constructive trust. These actions have been consolidated and are awaiting trial at the present time. Upon expiration of the lease respondent filed the present action in unlawful detainer. Appellants filed an answer denying the material allegations of the complaint and asserting eight affirmative defenses. For purposes of this appeal, we refer only to the second affirmative defense because of its singular importance to the issue before us. This affirmative defense stated that the real property was the subject matter of two other actions *67between the parties to determine title to the property. Specific reference is made to the actions by their numbers, namely, C279898, filed initially by the respondent, and SWC51914, subsequently filed by appellants. In addition to their answer appellants also filed a cross-complaint for fraud, unjust enrichment and for a constructive trust.
Appellants noticed a motion to consolidate the unlawful detainer action with the two pending superior court cases. In response to the cross-complaint respondent filed a demurrer, answer and motion to strike the cross-complaint. At a hearing on all of the various motions the court ruled as follows: (1) Appellants’ motion to consolidate was denied, and (2) respondent’s motion to strike the cross-complaint was granted.
Appellants filed a supersedeas writ with this court (another division) to stay trial based upon error and failure to grant appellants’ motion to consolidate. The supersedeas was denied for failing to state facts sufficient to issue the writ and the Supreme Court refused to grant a hearing on appellants’ request.
At the commencement of the unlawful detainer trial respondent submitted a motion in limine to exclude any evidence pertaining to the option agreements and to any of appellants’ claims to title. Appellants countered this motion with an offer of proof. They asked the court to take judicial notice that respondent had filed case No. C-279898 seeking to quiet title on the subject property and for declaratory relief to determine the validity of the lease and option agreement. They then offered to prove the following: (a) They entered into an oral agreement with respondent to purchase the Appoloosa Lane property for $700,000. Respondent wanted a tax-deferred exchange and to determine how this could be accomplished a meeting was held with a certified public accountant. He advised the parties that a single family residence could not qualify as a section 1031 exchange, but suggested that the residence be converted to income property for at least 18 months so that it could qualify, (b) Following this meeting the appellants prepared a lease and an option to purchase agreement and transmitted these documents to the certified public accountant for approval, (c) An attorney prepared the lease dated November 7, 1978, and prepared the option agreement which was dated 20 days later. The option agreement was an amendment to the lease and was incorporated in the lease by reference, (d) Even though the documents had different dates they were executed si*68multaneously and were in effect one document, (e) $60,000 was paid by appellants to respondent as consideration for the sale, (f) In addition to the monthly payments of $3,000 paid under the lease appellants expended $180,000 for major repairs and remodeling on the Appoloosa Lane property.
The trial court did take judicial notice of the two superior court cases, Nos. C-279898 and SWC51914. However, it then granted respondent’s motion to prevent any evidence concerning the option agreement or appellants’ claim to title. This, of course, limited the trial to a straight unlawful detainer action and the court found that the lease had expired and that respondent was entitled to possession plus damages for holding over by appellants at a fair rental value of $100 per day.
Discussion
The above facts disclose that this is not your usual garden variety type of unlawful detainer action. Not many lessees contract to install a tennis court, jacuzzi, and a new wing to the home under an 18-month lease. However, it is not the unusualness of the transaction that comes to the aid of appellants. As we will see later in this opinion, it is respondent’s own action in filing the first lawsuit between the parties to quiet title to the property and for declaratory relief that dictates the result of this appeal. We have refrained from summarizing in lengthy detail the summary nature of unlawful detainer actions. Most readers of this opinion will know that an unlawful detainer action is a proceeding designed to summarily determine if a lessor-lessee relationship existed between the parties and whether the lessor is entitled to possession of the property. Evidence on the issue of title is strictly limited. The tenant entrusted with possession by the landlord cannot justly dispute the validity of the landlord’s title unless he first restores possession to him. Therefore, the tenant in possession is estopped from denying the landlord’s title as it existed at the outset of the relationship. (Tewksbury v. Magraff (1867) 33 Cal. 237, 244; Yuba River Sand Co. v. City of Marysville (1947) 78 Cal.App.2d 421, 426 [177 P.2d 642]; 3 Witkin, Summary of Cal. Law (8th ed. 1973) Real Property, § 437, p. 2121.)2
*69As mentioned earlier in this opinion, there are a few exceptions to the rule that title cannot be tried in an unlawful detainer action. The exception that applies to this case is stated in 3 Witkin, supra, at page 2121: “The rule of estoppel to deny the landlord’s title is inapplicable in a number of situations . .. (4) Where the landlord puts his title in issue; e.g., where he sues for recovery of the premises, and also asks for a decree quieting title. In such case the tenant is not estopped from setting up title in himself, for, if he were, his claim would be adversely and finally determined without a hearing.” It is not necessary that the lessor raise the issue in the quiet title action. In Yuba River Sand Co. v. City of Marysville, supra, 78 Cal.App.2d 421, 425, the opinion states: “It is the established rule in California and in other jurisdictions that when a landlord not only seeks possession of real property, but also attempts to quiet title thereto as against the tenant, either by cross complaint or otherwise, the tenant is not estopped from denying the landlord’s title . . . .” (Italics added.)
Here respondent not only brought the first action to quiet title, he also sought declaratory relief. In American Enterprise, Inc. v. Van Winkle (1952) 39 Cal.2d 210 [246 P.2d 935], a case recognizing another exception to the rule that forbids a lessee from disputing his lessor’s title, the court noted (p. 219): “In an action for declaratory relief, the proper function of the court is to make a full and complete declaration, disposing of all questions of rights, status or other legal relations encountered in construing the instrument before it.” Due to the complexities of this case and the need to quiet title on the way to determining all of the issues, the most judicious approach would have been a consolidation of the three cases.3
We can appreciate the dilemma of the trial judge who was assigned the unlawful detainer action. The denial of the motion to consolidate left the inference that he should treat the case as a strict unlawful detainer action. He should not, however, particularly after taking judicial notice of the quiet title action filed by respondent, have dismissed appellants’ second affirmative defense that raised the issue of title. When *70an issue of title is acknowledged by the landlord by a prior quiet title action, the tenant is not estopped from challenging it in an unlawful detainer action that probably is brought by the lessor to gain a strategic victory. As noted earlier, the danger in not permitting the tenant to raise the issue of title is that his claim might be adversely and finally determined without a hearing. (See 3 Witkin, Summary of Cal. Law (8th ed. 1973) Real Property, § 437, p. 2121.) While we agree that trying title in the unlawful detainer action in this case would have prolonged the trial, the law as well as equity demanded such a trial in view of the refusal to consolidate.
The judgment is reversed.
Stephens, Acting P. J., and Ashby, J., concurred.
A petition for a rehearing was denied March 11, 1982, and respondent’s petition for a hearing by the Supreme Court was denied May 27, 1982. Kaus, J., did not participate therein.