Appeal from the Circuit Court of Cook County. Honorable Julia M. Nowicki, Judge Presiding.
 The opinion of the court was delivered by: Justice McNULTY
 In this case we must decide whether an insurer may recover amounts it paid for defense of its insured in a lawsuit against the insured for claims that do not fall within the coverage of the insurance policy. We hold that under the circumstances of this case, where the insured knew when it accepted the payments that the insurer intended to seek recovery of defense costs if the court agreed that the claims were not covered, the insurer may recover any payments made for the claims not covered by the policy.
 The City of Chicago (the City) and Cook County sued Midwest Sporting Goods for creating a public nuisance by selling guns to inappropriate purchasers. Midwest tendered defense of the lawsuit to its liability insurer, General Agents Insurance Company of America (Gainsco). Gainsco denied coverage, but in the letter it sent to Midwest's attorneys it wrote:
 "[W]ithout waiving any of its rights and defenses, including the right to recoup any defense costs paid in the event that it is determined that the Company does not owe the Insured a defense in this matter, the Company agrees to provide the Insured a defense in the captioned suit. In light of the competing interests between the Company and the Insured in respect of the coverage for this matter, the Company agrees to the Insured's selection and use of your firm as its counsel in this matter."
 Gainsco also sued for a judgment declaring that it had no duty to defend or indemnify Midwest.
 The trial court granted summary judgment in favor of Gainsco and this court affirmed that judgment on appeal. Gainsco then sought to recoup amounts it had paid for Midwest's defense costs. Between July 2000 and February 2001 Gainsco had paid Midwest's attorneys more than $40,000.
 The trial court again awarded judgment in favor of Gainsco, ordering Midwest to reimburse Gainsco for all payments Gainsco made to Midwest's attorneys in connection with the lawsuit. Midwest now appeals.
 Since the trial court granted judgment on uncontested evidence without holding an evidentiary hearing, we review the judgment de novo. See People v. Coleman, 183 Ill. 2d 366, 387-89 (1998).
 Midwest argues that Gainsco paid defense costs pursuant to the insurance contract, and the contract makes no provision for the recovery Gainsco seeks. According to Midwest, Gainsco cannot recover on a theory of unjust enrichment because a contract governs their relationship. We find that Midwest misconstrues the payments Gainsco made.
 When Midwest tendered defense of the lawsuit to Gainsco, Gainsco promptly denied coverage and sued for a judgment declaring that it had no duty to defend. But during the pendency of the declaratory judgment action, while the court undertook the process needed to determine whether Gainsco owed Midwest any defense, Gainsco offered to pay part of Midwest's costs of defending the City's lawsuit -- with the qualification that Gainsco would seek reimbursement if the court determined that it owed no duty to defend.
 We find the arrangement similar to the arrangement made between the parties in City of Chicago v. McKechney, 205 Ill. 372 (1903). In that case the City in 1895 agreed to pay McKechney to construct a tunnel. In 1897 McKechney demanded increased payments because he encountered unexpected difficulties in the course of construction. When the City made a partial payment at the original rate rather than the increased rate, McKechney stopped work and sued the City. He claimed that the inadequate payments violated an 1897 revision of the original contract.
 The City denied liability but sought to have the work resumed. In 1898 the City and McKechney made a new arrangement for resumption of the work pending determination of the parties' rights in the lawsuit. Under the 1898 agreement the City promised to pay McKechney at a rate higher than the agreed rate stated in the 1895 contract, but
 "'without prejudice *** so that the final judgment or decree may be in accordance with the rights of the parties upon the merits, as determined by the court, independent of such arrangement for the resumption of the work. In the final adjustment the city to receive credit for all moneys paid to said contractors on any account in connection with the construction ***, and in the event that an over-payment shall be found to have been made, the city to be entitled to recover the amount of such over-payment.'" McKechney, 205 Ill. at 436-37.
 McKechney claimed that the City made its subsequent payments under the 1897 revision, thereby acknowledging that revision as a binding contract. Our supreme court rejected that argument. Instead the court found that the 1898 accommodation pending litigation effectively preserved the City's rights under the 1895 contract, including the right to pay no more than the amount due thereunder. The court held that the 1897 document did not effectively revise the 1895 contract. The City recovered amounts paid under the 1898 accommodation in excess of amounts owed under the 1895 contract.
 Here, Gainsco offered a similar accommodation pending litigation to determine whether Gainsco owed Midwest the cost of defending the lawsuit the City of Chicago brought against Midwest. Like the 1898 arrangement in McKechney, the accommodation proposed in Gainsco's letter reserved rights to litigate the question of whether Gainsco owed the payments sought, and the right to recover any amounts the court ...