
    DR. JOSÉ S. BELAVAL, INC., Plaintiff, Appellant, Rio Grande Community Health Center, Inc.; Concilio De Salud Integral De Loiza, Inc. (CSILO), Plaintiffs, v. Rosa PÉREZ-PERDOMO, Secretary, Department of Health of the Commonwealth of Puerto Rico, Defendant, Appellee, Commonwealth of Puerto Rico; United States Department of Health and Human Services; Michael Leavitt, Secretary, United States Department of Health and Human Services, Defendants.
    No. 07-1240.
    United States Court of Appeals, First Circuit.
    Heard May 7, 2007.
    Decided May 18, 2007.
    
      Robert A. Graham, with whom James L. Feldesman, Feldesman Tucker, Leifer Fi-dell LLP and Ignacio Fernandez de La-hongrais were on brief, for appellant.
    Francisco J. Amundaray and Mercado & Soto, P.S.C. on brief for Municipality of San Juan, amicus curiae.
    Luis A. Rodriguez-Muñoz, with whom Eduardo Vera-Ramirez, Eileen Landrón-Guardiola, Landrón & Vera, LLP, Roberto Sánchez-Ramos, Secretary of Justice, and Salvador Antonetti-Stutts, Solicitor General, were on brief for appellee.
    Before LYNCH, LIPEZ, and HOWARD, Circuit Judges.
   LYNCH, Circuit Judge.

This case is part of a continuing saga of Puerto Rico’s attempts to avoid paying money owed to a medical provider under federal Medicaid law. Plaintiff Dr. José S. Belaval, Inc. is a federally-qualified health center (“FQHC”) under the federal Medicaid statute. Federal law entitles Belaval to certain payments from Puerto Rico, see 42 U.S.C. § 1396a(bb), and when Puerto Rico failed to set up a system for making those payments, Belaval successfully obtained a preliminary injunction in 2004 requiring Puerto Rico to do so prospectively. Much of the background behind this case is set out in our two earlier opinions pertaining to this litigation. See Dr. José S. Belaval, Inc. v. Pérez-Perdomo, 465 F.3d 33 (1st Cir.2006) (reinstating an injunction that required payment to Belaval and that had been erroneously modified); Rio Grande Cmty. Health Ctr., Inc. v. Rullan, 397 F.3d 56 (1st Cir.2005) (affirming an order of relief requiring prospective payment to one of Belaval’s co-plaintiffs).

The Commonwealth’s third appearance before us stems from the Puerto Rico Supreme Court’s decision in Municipality of San Juan v. Board of the José S. Belaval Community Health Center, Inc., No. CC-2005-716 (P.R. Oct. 10, 2006). In that decision, the Puerto Rico Supreme Court determined that Belaval had been operating its facilities without a valid contract with its landlord, the Municipality of San Juan. The Commonwealth sought to use this decision as a basis for avoiding its obligation to make the federally required payments. The federal district court decided that Belaval lacked “clean hands,” and the court deprived Belaval of over a year’s worth of payments it had been owed under the earlier injunction. The district court erred in its application of the unclean hands doctrine and in the relief it granted the Commonwealth. We reverse and remand to the district court.

I.

We recount only the key points from the history of this litigation, supplemented with the facts that arose after our October 2, 2006 decision in Belaval.

Because of Puerto Rico’s failure to make the statutorily required Medicaid payments, three FQHCs filed suit in June 2003 seeking prospective injunctive relief from the federal district court. Belaval, the sole appellant now before us, was one of the three FQHC plaintiffs. The defendant was the Secretary of the Department of Health of the Commonwealth of Puerto Rico.

On November 1, 2004, the district court adopted a magistrate judge’s report and recommendation, and it granted the plaintiffs a preliminary injunction. Under the terms of the injunction, the defendant was required (among other things) to make quarterly “wraparound” payments starting from the second quarter of 2004. Several months later, we issued our decision in Rio Grande, which pertained to a similar injunction previously issued for one of Be-laval’s co-plaintiffs. We rejected the Commonwealth’s arguments that it was improper for a federal court to issue such an injunction. See Rio Grande, 397 F.3d at 68-75.

Yet by August 12, 2005, Puerto Rico still had failed to make a single payment to Belaval, and so on that date Belaval asked the district court to issue an order to show cause why the defendant Secretary should not be held in contempt. The magistrate judge issued the order, and then after receiving the defendant’s response, issued a report and recommendation finding that the defendant was not in compliance with the November 1, 2004 order. The magistrate judge also acknowledged that Bela-val’s August 12 motion requested that defendant be held in contempt, and the judge recommended that this request be held in abeyance so that the defendant could be given several weeks to comply with the injunction.

In an opinion issued October 6, 2005, the district court adopted the key parts of the magistrate judge’s report and recommendation. But the district court also sua sponte modified the preliminary injunction so that it would only take effect beginning with the third quarter of 2005. This erroneous sua sponte modification relieved the defendant of several quarters’ worth of payments. When Belaval took an interlocutory appeal, we reversed this modification because, inter alia, it had been made without providing notice and a hearing for Belaval. See Belaval, 465 F.3d at 37-38. Our Belaval opinion issued on October 2, 2006.

The next day, and in light of our decision, the district court (under a different judge to whom the case had been assigned) released a two-part order. First, the court ordered Belaval to submit, by October 18, 2006, a memorandum with supporting evidence explaining how much it was owed under the terms of the original injunction. Second, the court ordered the Secretary to respond to Belaval’s filing by October 30, 2006. Belaval timely submitted its memorandum and accompanying evidence. However, the Secretary did not respond by the required date. Thus, on October 31, 2006, the district court ordered the defendant to pay Belaval $6,772,549, and further ordered the defendant to deposit this amount with the Clerk of Court by November 9, 2006.

On November 8, 2006, the defendant asked for an extension of time to deposit the required funds, and also filed a motion for reconsideration of the court’s October 31 order. Most of the motion was geared towards arguments that the $6.7 million figure was too high, that more discovery was needed to determine the correct amount, and that in any event a hearing was needed on whether the district court should reinstate the injunction modification that had been imposed prior to our decision in Belaval. The motion also briefly noted that the Puerto Rico Supreme Court had, on October 10, 2006, issued an (apparently unpublished) opinion in a case about a landlord-tenant dispute between Belaval and the Municipality of San Juan (the “San Juan opinion”).

As that opinion recounts, San Juan owns the physical structure, and the equipment, at the location where Belaval had been providing its health services. Since 1986, Belaval had leased its space from the municipality, but the lease expired on June 30, 2002. Belaval nonetheless continued to operate and provide medical services at that location, beyond the period of occupancy under the terms of the lease. After unsuccessfully attempting to evict Belaval, San Juan filed suit against Belaval in the Puerto Rico Court of First Instance. The municipality sought a declaratory judgment that there was “no contract or valid title that would allow [Belaval] to continue operating” the facilities, and it also sought damages. The Court of First Instance issued a partial declaratory judgment that the contract between the parties had expired on June 30, 2002. The Puerto Rico Supreme Court upheld that partial judgment on appeal, pointing out that because this was a government contract with a municipality, Puerto Rico law required any contract to be in writing, which precluded Belaval from arguing that there had been an implicit renewal of the agreement. That is all that the case decided. No assessment of damages was made, and the case was remanded to the Court of First Instance to continue proceedings.

Back in federal court, on November 13, 2006, the district court denied the Secretary’s motion for reconsideration, pointing out that the Secretary’s arguments should have been raised before the filing deadline had passed. However, the court did grant the requested extension of time to deposit the funds (although it expressed some frustration with the defendants). It also directed the parties to discuss the effect of the San Juan opinion — if any — on the payments owed to Belaval. The court further ordered that San Juan be given notice in case it wished to try to intervene in the case, and the court indicated that once the Secretary in fact paid the funds to the court, those funds would remain with the court pending further order. The Secretary did eventually deposit the funds.

Perhaps prompted by the district court’s order, San Juan filed a motion to intervene on December 11, 2006. San Juan alleged that Belaval owed it over $5 million, and it asked the federal court to order the attachment of $5,276,127.06 out of the funds to be deposited with the federal court. The district court ordered all parties to show cause why Belaval’s funds should not be attached as requested, and deposited with the Court of First Instance. The parties filed their responses on December 20, 2006.

The same day, and reacting to the district court’s earlier order from November 13, the defendant Secretary filed a memorandum of law regarding the effect of the San Juan opinion. Eight days later, and apparently in response to this memoran-chim, the district court dismissed Belaval as a party to the case and authorized the Commonwealth to withdraw the funds it had deposited with the court. In a short order, and without citing any case law or other authority (beyond the San Juan opinion), the district court determined that Belaval “should not have been operating at the time this federal action was commenced,” and so Belaval did not have “clean hands” to seek the equitable remedy of a preliminary injunction. Because the court had dismissed Belaval from the action, it denied as moot San Juan’s motion to intervene. Later that same day, the Secretary withdrew the funds she had deposited.

The December 28 order was entered without the benefit of a response from Belaval. The next day, Belaval filed a motion for reconsideration, and it asked that it be able to file an opposition to the Secretary’s arguments. Then, before the district court ruled on this motion, Belaval submitted an opposition “on the assumption the Court grants our request for reconsideration.” The district court denied the motion for reconsideration, stating that it had considered Belaval’s opposition, and that the court would nonetheless reaffirm its earlier order.

Belaval appeals.

II.

Belaval’s appeal challenges both the substance and the procedure of the district court’s decision. We bypass Belaval’s procedural arguments.

Our merits analysis goes straight to evaluating the district court’s use of the unclean hands doctrine. Our review is for abuse of discretion, see K-Mart Corp. v. Oriental Plaza, Inc., 875 F.2d 907, 912 (1st Cir.1989), and an error of law constitutes an abuse of discretion, see Top Entm’t, Inc. v. Torrejon, 351 F.3d 531, 533 (1st Cir.2003). On the facts presented, the district court both committed an error of law and abused its discretion in finding that the unclean hands doctrine was applicable, and then in dismissing Belaval’s case and releasing the deposited funds.

The doctrine of unclean hands, or, more archaically, the maxim that “[h]e who comes into equity must come with clean hands,” Keystone Driller Co. v. Gen. Excavator Co., 290 U.S. 240, 241, 54 S.Ct. 146, 78 L.Ed. 293 (1933), finds its roots in traditions of equity jurisprudence that predated the merger of law and equity. See id. at 244-45, 54 S.Ct. 146; see also Shondel v. McDermott, 775 F.2d 859, 867-68 (7th Cir.1985) (discussing the relationship of the doctrine to the “moralistic ... jurisprudence created by the Lord Chancellors of England when the office was filled by clerics”) (Posner, J.). The basic premise is that when a district court considers whether or not to award equitable relief, one factor that it must consider is the extent to which the plaintiff has engaged in certain misconduct. See Texaco P.R., Inc. v. Dep’t of Consumer Affairs, 60 F.3d 867, 880 (1st Cir.1995).

The doctrine has limits, and not all misconduct by a plaintiff will soil that plaintiffs hands. Among other things, the doctrine “only applies when the claimant’s misconduct is directly related to the merits of the controversy between the parties, that is, when the tawdry acts ‘in some measure affect the equitable relations between the parties in respect of something brought before the court for adjudication.’ ” Id. (quoting Keystone, 290 U.S. at 245, 54 S.Ct. 146). The mere fact that the “misconduct” arises from some overlapping facts is not enough. Since “relatively few plaintiffs are wholly free from any trace of arguable misconduct at least tangentially related to the objective of their suit, the right to injunctive relief ... would have little value if the defendant could divert the proceeding into the byways of collateral misconduct.” Shondel, 775 F.2d at 869.

In this case, there was no relationship between Belaval’s underlying suit against Puerto Rico for payment for services provided under the federal Medicaid statute, and Belaval’s Puerto Rico law contract dispute with San Juan. Belaval’s entitlement to payment from the Secretary turns on whether or not it meets the definition of an FQHC, and whether or not it provides medical services. See 42 U.S.C. §§ 1396a(bb), 1396d(l)(2)(B). There is no dispute that Belaval was an FQHC during the relevant time, and that Belaval provided the relevant services. The district court nevertheless justified its actions on the ground that Belaval “should not have been operating” at the time this federal action commenced. That justification is error, and the two questions are unrelated. At most, the Commonwealth’s argument could be that Belaval should not have been operating at the specific facility owned by San Juan. But Belaval’s entitlement to payment does not turn on whether it operated at that specific facility. The fact that Belaval may have overstayed its lease does not directly relate to the controversy between the parties in the federal case.

The Secretary nonetheless protests that Belaval’s operation was “illegal,” and defendant worries that “the possibilities of fomenting illegal operations would be encouraged if Belaval is allowed to receive any amount for their illegal operation.” Defendant contends that Puerto Rico will be injured if “public funds [are] disbursed to an entity that carried on an illegal operation.”

This argument still fails to establish relatedness. Although the Secretary says that Belaval operated “illegally,” she does not even suggest that payment to Belaval would be impermissible under the federal Medicaid statute. Rather, her main point is that under Puerto Rico law, Belaval was required to have a written contract with San Juan if it wished to have an enforceable lease. This “illegality” is not related to Puerto Rico’s failure to make statutorily required Medicaid payments. There is no reason to think that these federally required payments can be displaced by local landlord-tenant law.

As we observed in our prior opinion, Belaval has been pushed to “the brink of financial ruin” because of Puerto Rico’s continuing failure to make the required payments. Belaval, 465 F.3d at 36 n. 2. We note that San Juan, as amicus on appeal, opposes the relief granted the Commonwealth and supports Belaval.

III.

Notwithstanding all of the above, the Secretary appears to make a last ditch argument that the San Juan opinion has somehow transformed Belaval’s collection efforts into attempts to obtain retroactive monetary relief, which would then be barred by the Eleventh Amendment. This confusing claim is without merit. As we determined in Rio Grande, the plaintiffs in this case face no Eleventh Amendment bar because they have sought prospective in-junctive relief. 397 F.3d at 75-76; cf. Edelman v. Jordan, 415 U.S. 651, 668-71, 94 S.Ct. 1347, 39 L.Ed.2d 662 (1974). Neither the fact that the Commonwealth has managed to avoid its obligations under an injunction that was issued prospectively, nor the fact that Belaval has been operating without a contract with San Juan, affects this in any way.

IV.

The district court’s December 28, 2006 judgment is reversed. The case is remanded, and the district court is instructed promptly to reinstate the case, to restore and enforce the payment obligation created by its October 31, 2006 order, and to supplement the payment amount from the Commonwealth with an increase to reflect lost interest to Belaval at the appropriate rate.

The issue of whether San Juan may seek to attach funds in the federal proceeding after remand, even though (as we understand it) the municipality is not yet a judgment creditor, is not before us.

Costs are awarded to Belaval. 
      
      . The actual deposit did not occur until December 22, 2006, and it came only after the defendant sought additional extensions.
     
      
      . Defendant briefly speculates that if another entity had occupied San Juan’s premises, it might have operated more efficiently, thereby requiring Puerto Rico to spend less money in reimbursements. This is sheer speculation and irrelevant.
     
      
      . Defendant also briefly asserts, without any citation to any sources of law, that it would violate Puerto Rico law if the Commonwealth paid funds to an entity that operated without a written contract. "[I]ssues adverted to in a perfunctory manner, unaccompanied by some effort at developed argumentation, are deemed waived.” United States v. Zannino, 895 F.2d 1, 17 (1st Cir.1990).
     