
435 N.W.2d 861 (1989)
Calvin E. HESSELGRAVE, Respondent,
v.
Milton HARRISON, Appellant.
No. CX-88-1898.
Court of Appeals of Minnesota.
February 21, 1989.
Review Denied April 24, 1989.
*862 Frank T. Mabley, Greenstein, Mabley & Wall, Roseville, for respondent.
Larry E. Reed, Hassan & Reed, Ltd., Minneapolis, for appellant.
Heard, considered and decided by CRIPPEN, P.J., and RANDALL and BOWEN,[*] JJ.

OPINION
ROBERT E. BOWEN, Acting Judge.
Harrison appeals from a summary judgment determining that he was unjustly enriched and liable to Hesselgrave for restitution. We reverse and remand for entry of judgment in favor of appellant.

FACTS
In April 1980, Harrison purchased a home from Hesselgrave and financed the purchase by a second mortgage in favor of Hesselgrave, which was duly recorded. Hesselgrave had previously encumbered the property with a first mortgage which Harrison did not assume.
The terms of the second mortgage provided that Harrison was not to encumber the property further. However, Harrison allowed five additional mortgages totalling approximately $170,000 to be recorded against the property, and 13 federal and state tax liens totalling approximately $80,000 were filed against him. All of these encumbrances were recorded after and were junior to the second mortgage in favor of Hesselgrave.
Harrison defaulted on his payments under the second mortgage and was served with a notice of foreclosure by advertisement in December 1984. Foreclosure proceedings ensued, and Hesselgrave's attorney attempted to give all of the junior lienholders notice of the impending sheriff's sale and the period allowable for redemption. After the period of redemption had lapsed, all of the encumbrances recorded junior to the second mortgage were eliminated, except those held by the Internal Revenue Service (IRS), which survived because Hesselgrave's attorney failed to give the IRS the notice required by 26 U.S.C. § 7425. Consequently, the IRS liens had priority over the foreclosed second mortgage and constituted a cloud on Hesselgrave's title. (The parties do not dispute that had the IRS received the required notice, its lien would have remained junior and would have been eliminated by the foreclosure unless the IRS elected to redeem.)
When Hesselgrave discovered the cloud on his title, he also learned that foreclosure of the first mortgage was imminent. In order to sell the property and thereby preserve his equity, Hesselgrave had to convey clear marketable title. He negotiated a $25,000 payment to the IRS for the release of its liens against the property, thereby clearing his title and allowing him to sell the property.
Hesselgrave then brought this action claiming that Harrison has been unjustly enriched by the $25,000 payment to the IRS. Harrison moved for dismissal for failure to state a claim, and Hesselgrave moved for summary judgment. After a hearing on the parties' motions, the trial court found in its May 3, 1988, order that Harrison had been unjustly enriched and granted summary judgment in favor of Hesselgrave for $25,000. The trial court treated both motions as motions for summary judgment, found that both parties agreed there were no disputes as to any facts, and held that Hesselgrave was entitled to judgment as a matter of law. On June 8, 1988, judgment entered and Harrison appealed.

ISSUE
Did the trial court err in granting summary judgment to Hesselgrave?


*863 ANALYSIS

I.
On appeal from a summary judgment, it is the reviewing court's function to determine (1) whether there are any genuine issues of material fact and (2) whether the trial court erred in its application of the law. Huber v. Niagara Machine & Tool Works, 430 N.W.2d 465, 467 (Minn.1988). We agree with the trial court that there are no material facts in dispute, but hold that the trial court erred in its application of the law.

II.

A. Motion

Harrison first contends that the trial court erred in its determination that both parties were moving for summary judgment. He claims he moved for a dismissal and not for summary judgment. Although Harrison's motion as filed was for a dismissal, he later filed an affidavit setting forth facts clearly beyond those alleged in Hesselgrave's complaint. The trial court necessarily considered the matters addressed in the affidavit, and therefore correctly treated Harrison's motion as one for summary judgment. See Minn.R.Civ.P. 12.03.

B. Material Facts

Harrison next contends that the trial court erred in determining the parties had agreed that there were no factual disputes between them. Harrison argues that he did not agree with all the facts alleged by Hesselgrave, and points to his own affidavit as evidence of his disagreement with Hesselgrave's version of the facts. He also contends the trial court erred when it decided two factual issues that were appropriate for jury determination: (1) "the defendant could not have escaped the claim of the Internal Revenue Service" and (2) "the plaintiff did an excellent job of negotiating with the Internal Revenue Service." As a result of these claimed errors, Harrison alleges he "was entitled to a dismissal or at the very least, trial."
Summary judgment is proper where no factual disputes are raised, where the parties are concerned only with the meaning or the legal consequences of the facts, and where determination of the applicable law will resolve the controversy. See Holiday Acres No. 3 v. Midwest Federal Savings & Loan Association of Minneapolis, 308 N.W.2d 471, 480 (Minn.1981).
Even though Harrison views the matters raised in his affidavit concerning the value of his equity in the property, the value of the mortgage filed against the property and the value of the tax liens filed against the property as material facts, the determination of these matters is merely a legal consequence of Harrison's liability to third parties. Harrison does not take issue with the fact or amount of Hesselgrave's payment to the IRS. The parties did not dispute those facts material to Hesselgrave's claim of unjust enrichment.
The trial court's statement that Harrison could not escape the IRS's claims appears to be a conclusion reached from the court's interpretation of applicable statutes and not from a determination of the facts presented on the record. The trial court's remarks concerning Hesselgrave's negotiation abilities deal with neither fact nor law, and are gratuitous, having no effect on the case's disposition. Consequently, the trial court was not presented with any genuine issue of material fact. Although the record does not support the court's statement that the parties agreed that no facts were in dispute, the parties' agreement or lack of it does not affect the trial court's duty to determine whether there are any material fact issues to be resolved. The trial court correctly determined that no fact issues were presented for resolution.

C. Interpretation of Law

Harrison disputes the trial court's finding that he was unjustly enriched.
"An action for unjust enrichment may be based on failure of consideration, fraud, mistake, and situations where it would be morally wrong for one party to enrich himself at the expense of another." Anderson v. DeLisle, 352 N.W.2d 794, 796 (Minn.Ct.App.1984). However, a claim of *864 unjust enrichment does "not lie simply because one party benefits from the efforts or obligations of others, but instead lies where one party was unjustly enriched in the sense that the term `unjustly' could mean illegally or unlawfully." Christle v. Marberg, 421 N.W.2d 748, 751 (Minn.Ct. App.1988). See also First National Bank of St. Paul v. Ramier, 311 N.W.2d 502, 504 (Minn.1981).
A mortgage foreclosure sale alone is not an illegality giving rise to an unjust enrichment claim. See Thompson Plumbing Co. v. J.E.C., Inc., 422 N.W.2d 26, 28-29 (Minn.Ct.App.1988); see also Christle, 421 N.W.2d at 751 (although the trial court found that the real estate developer had received a substantial monetary benefit from contractor's improvements, contractor's failure to give the statutory pre-lien notice barring a mechanic's lien foreclosure action was not an "illegal or unlawful action" giving rise to an unjust enrichment claim). But see Anderson, 352 N.W. 2d at 796 (court of appeals upheld a jury's finding of unjust enrichment, in effect concluding that the vendors' conduct amounted to illegal or criminal actions. The vendors (1) stood silent and watched plaintiff make extensive improvements to their property, (2) contracted to retain those improvements upon default, and (3) knew that because of plaintiff's financial problems there was little or no chance that he could perform under the contract.). Id.
Here, Hesselgrave did not present any evidence that Harrison engaged in illegal activities or improprieties in order to benefit from Hesselgrave's $25,000 payment to the IRS. Hesselgrave elected his remedy of foreclosure by advertisement upon Harrison's default. The IRS lien's survival was the result, not of any further wrongdoing on the part of Harrison, but of Hesselgrave's failure to follow statutory procedures in connection with the foreclosure. Even after his discovery that the IRS lien had survived as a cloud on his title, he could have begun the foreclosure by advertisement anew and extinguished the IRS lien. Instead, as a result of his own default in payments on the first mortgage (which Harrison did not assume) and the resulting pressure to complete a quick sale and preserve his equity, Hesselgrave elected to negotiate for a release of the IRS lien. Hesselgrave's decision to pay the IRS was reached without any influence from or participation by Harrison. Consequently, the trial court's finding of unjust enrichment is unsupported by the record.

DECISION
We reverse and remand to the trial court with instructions to vacate the judgment in favor of Hesselgrave and to enter judgment in favor of Harrison.
REVERSED AND REMANDED.
NOTES
[*]  Acting as judge of the court of appeals by appointment pursuant to Minn. Const. art. VI, § 2.
