
344 N.W.2d 273 (1983)
Linda S. EWURS and Arthur L. Peterson, Plaintiffs-Appellants,
v.
Paul IRVING and Colleen Irving, Defendants-Appellees.
No. 83-147.
Court of Appeals of Iowa.
November 30, 1983.
*274 *275 Robert W. Powers, Des Moines, for plaintiffs-appellants.
Frank M. Smith of the Frank Smith Law Office, and Dale T. Baker, Des Moines, for defendants-appellees.
Considered by OXBERGER, C.J., and DONIELSON, SNELL, SCHLEGEL, HAYDEN, and SACKETT, JJ.
SCHLEGEL, Judge.
The plaintiffs, buyers under a real estate contract, appeal from the trial court's decision dismissing their petition for declaratory judgment and injunctive relief which sought a judgment regarding the parties' legal rights and obligations under the contract. The trial court determined that the action for declaratory judgment should be dismissed because the action was inappropriate in light of the existing remedies provided under Iowa Code chapters 648 and 656 (1981), because the action would not terminate the uncertainty or controversy giving rise to the proceeding, and because the matter could only be determined by a long investigation of matters of fact. The trial court also determined that the requested injunctive relief was inappropriate because plaintiffs have an adequate remedy at law. We reverse and remand.
The plaintiffs' petition alleges in relevant part that plaintiffs and defendants are parties to a real estate contract and that the parties are unable to resolve a dispute involving payments on that contract. Plaintiffs further allege that the defendants have threatened to serve a notice of forfeiture of the real estate contract as a result of plaintiffs' alleged failure to make certain payments, specifically set out in the petition in the amount of $347.30. Plaintiffs deny owing any of that amount. Plaintiffs allege the defendants have failed to give them certain credits and to maintain certain insurance policies allegedly required under the real estate contract. Plaintiffs also state that the threatened forfeiture of the contract would deprive them of monies paid in excess of $1100 on the contract and terminate all of their interest in the real estate. Plaintiffs request that the court, pursuant to Iowa Rules of Civil Procedure 261 and 262, render a declaratory judgment regarding the legal rights and relations of the parties to the contract.
Defendants rely upon and argue five propositions for affirmance: 1) no claim was stated showing that the issue was concrete and that particular legal rights and powers could be affected; 2) there were other more appropriate remedies available; 3) the relief requested would not terminate the uncertainty or controversy giving rise to the proceedings; 4) the issues stated could only be determined by long investigation of matters of fact; and 5) the trial court had broad discretion to refuse to grant declaratory relief.
"A motion to dismiss admits, and is decided solely upon, all facts well pleaded. It is only sustainable when it appears to a certainty the pleader has failed to state a claim on which relief may be granted." Dunn v. Rose Way, Inc., 333 N.W.2d 830, 831 (Iowa 1983) (citations omitted). These principles apply to declaratory judgment actions as well as other actions. Wright v. Thompson, 254 Iowa 342, 347, 117 N.W.2d 520, 523 (1962). The issue on a motion to dismiss a petition for declaratory relief is whether plaintiffs have stated a claim for declaratory relief, not whether the relief could be granted on the theory of the contract. Id. at 350-351, 117 N.W.2d at 525. We believe, for reasons set out below, that the claim presented a proper case for invoking the jurisdiction of the court to make a declaratory judgment. Accordingly, the trial court erred in sustaining the motion to dismiss.
First, we reject defendants' alleged grounds for dismissal numbers three and five because the grant or denial of a motion to dismiss does not rest in the discretion of the trial court; it must be determined *276 upon legal grounds and is subject to review by this court. Moravek v. Davenport Community School District, 262 N.W.2d 797, 800 (Iowa 1978). Iowa Rule of Civil Procedure 265 provides that "[t]he court may refuse to render a declaratory judgment or decree where it would not, if rendered, terminate the uncertainty or controversy giving rise to the proceeding." This discretion may be exercised only at such time during the trial when the court has the evidence before it and can properly make a final determination. It should not be exercised on a motion to dismiss. Wright v. Thompson, 254 Iowa at 350, 117 N.W.2d at 525. Trial court's purported exercise of discretion upon grounds three and five was improper.
Likewise, we reject defendants' alleged ground for dismissal number two. The existence of another remedy does not preclude a judgment for declaratory relief in cases where it is appropriate. Iowa R.Civ.P. 261. The test in each case is whether or not the legislature has prescribed an exclusive remedy. Id. at 352, 117 N.W.2d at 526. Neither Iowa Code chapter 648 (1981), nor Iowa Code chapter 656 (1981), require a vendee in a real estate contract to wait until the vendor has brought an action under those statutes and to present their claims only in defense of those actions. Nor do defendants point to any provision in those chapters or any other requiring a vendee's inaction.
We also reject defendant's alleged ground for dismissal number four. That it may involve in part fact questions is insufficient basis for withholding declaratory relief. Id. at 353, 117 N.W.2d at 527. If a jury trial is demanded on fact questions that could have been tried in a law action, it must be assumed the court would grant it. Iowa R.Civ.P. 268.
Defendant's alleged ground for dismissal number one is also without merit. The defendants' argument raises the issue of whether this controversy is justiciable. The underlying question is "whether the facts alleged show there is a substantial controversy between parties having adverse legal interests of sufficient immediacy and reality to warrant a declaratory judgment." Erickson v. Christensen, 261 N.W.2d 171, 172 (Iowa 1978). Clearly, both parties stand to gain or lose by a ruling on their respective rights under this contract. The facts, as alleged in the petition, show a continuing controversy between these two parties with opposing interests. This controversy has proceeded beyond the stage of mere apprehension or fear that defendants will claim adversely to plaintiffs' rights. See Bechtel v. City of Des Moines, 225 N.W.2d 326, 330-32 (Iowa 1975). The defendants, under the facts pleaded, contest the amount the plaintiffs owe under the terms of the real estate contract and threaten forfeiture of that contract. There is a substantial controversy between these parties of sufficient immediacy and reality to warrant a declaratory judgment. The plaintiffs have stated a claim for declaratory relief.
Because we have found that the trial court improvidently granted the defendants' motion to dismiss in this declaratory judgment action, we reverse and remand for further proceedings not inconsistent with our decision.
REVERSED AND REMANDED.
