
    STILLAGUAMISH TRIBE OF INDIANS, a Federally-Recognized Indian Tribe, Plaintiff-Appellee, v. State of WASHINGTON; Robert W. Ferguson, in His Official Capacity as Attorney General of Washington, Defendants-Appellants.
    No. 17-35722
    United States Court of Appeals, Ninth Circuit.
    Argued and Submitted November 8, 2018 Seattle, Washington Filed January 22, 2019
    Alan D. Copsey (argued), Deputy Solicitor General; Rene D. Tomisser, Senior Counsel; Robert W. Ferguson, Attorney General; Attorney General's Office, Olympia, Washington; for Defendants-Appellants.
    Rob Roy (argued), Kilpatrick Townsend & Stockton LLP, Seattle, Washington; Scott Mannakee, Stillaguamish Tribe of Indians, Arlington, Washington; for Plaintiff-Appellee.
    Before: M. Margaret McKeown and Michelle T. Friedland, Circuit Judges, and Susan R. Bolton, District Judge.
    
      
      The Honorable Susan R. Bolton, United States District Judge for the District of Arizona, sitting by designation.
    
   McKEOWN, Circuit Judge:

In an effort to engineer federal jurisdiction, the Stillaguamish Tribe of Indians ("the Tribe") sued the State of Washington in federal court, seeking a declaration that the Tribe's sovereign immunity barred any lawsuit arising from a particular contract with Washington. The trouble with this approach is that the Tribe's anticipatory defense to a state court lawsuit does not net federal jurisdiction.

In 2005, the Tribe's Environmental Manager signed an agreement with Washington concerning construction of a revetment to protect salmon populations in the Stillaguamish River. The details of the agreement are unimportant here, except for an indemnification provision, which obligated the Tribe to "indemnify, defend and hold harmless [Washington] from and against all claims ... arising out of or incident to the [Tribe's] ... performance." After a tragic landslide near the Stillaguamish River, Washington became embroiled in litigation. Victims of the slide alleged the revetment had contributed to their injuries. Washington indicated repeatedly that it would seek indemnification from the Tribe, both while the litigation was ongoing and after the resulting settlement.

In response, the Tribe sued Washington in federal district court, seeking to establish that the Tribe's sovereign immunity would bar a suit for indemnification. The district court granted summary judgment in favor of the Tribe.

We do not reach the merits of the Tribe's sovereign immunity defense because we conclude, on de novo review, that the district court lacked subject matter jurisdiction. Kingman Reef Atoll Invs., LLC v. United States , 541 F.3d 1189, 1195 (9th Cir. 2008) (holding that whether subject matter jurisdiction exists is reviewed de novo).

The Tribe invokes federal question jurisdiction under 28 U.S.C. § 1331, which provides for jurisdiction over "all civil actions arising under the Constitution, laws, or treaties of the United States." Under the well-pleaded complaint rule, federal question jurisdiction exists only if the plaintiff's cause of action is based on federal law. See Metro. Life Ins. Co. v. Taylor , 481 U.S. 58, 63, 107 S.Ct. 1542, 95 L.Ed.2d 55 (1987). Neither a defense based on federal law nor a plaintiff's anticipation of such a defense is a basis for federal jurisdiction. See Aetna Health Inc. v. Davila , 542 U.S. 200, 207, 124 S.Ct. 2488, 159 L.Ed.2d 312 (2004) ; Bodi v. Shingle Springs Band of Miwok Indians , 832 F.3d 1011, 1023 n.16 (9th Cir. 2016) ("A tribal immunity defense does not provide an independent basis for federal jurisdiction.").

Parties cannot circumvent the well-pleaded complaint rule by filing a declaratory judgment action to head off a threatened lawsuit. See Atay v. Cty. of Maui , 842 F.3d 688, 697-98 (9th Cir. 2016). When a declaratory judgment action "seeks in essence to assert a defense to an impending or threatened state court action," courts apply the well-pleaded complaint rule to the impending or threatened action, rather than the complaint seeking declaratory relief. Id. In other words, "the character of the threatened action, and not of the defense" determines whether there is federal-question jurisdiction. Id. at 698 ; accord Medtronic, Inc. v. Mirowski Family Ventures, LLC , 571 U.S. 191, 197, 134 S.Ct. 843, 187 L.Ed.2d 703 (2014).

The Tribe points out that tribal sovereign immunity is a question of federal common law. True enough. Kiowa Tribe of Okla. v. Mfg. Techs., Inc. , 523 U.S. 751, 754, 118 S.Ct. 1700, 140 L.Ed.2d 981 (1998). But tribal immunity is a federal defense . Okla. Tax Comm'n v. Graham , 489 U.S. 838, 841 (1989) (per curiam). As such, "[t]he possible existence of a tribal immunity defense ... did not convert [Washington contract claims] into federal questions, and there was no independent basis for original federal jurisdiction." Id. It makes no difference that the Tribe asserted its defense in a declaratory judgment action rather than in a lawsuit brought by the state.

We are not persuaded by the Tribe's reliance on Shaw v. Delta Air Lines, Inc. , 463 U.S. 85, 103 S.Ct. 2890, 77 L.Ed.2d 490 (1983). In Shaw , the Supreme Court reiterated that "[a] plaintiff who seeks injunctive relief from state regulation, on the ground that such regulation is pre-empted by a federal statute ... presents a federal question." Id. at 96, n.14, 103 S.Ct. 2890. The Tribe is asserting a defense to a threatened lawsuit, not contending that federal law preempts state law. The rule from Shaw is inapplicable. Holding otherwise would permit any potential defendant faced with a state common law action brought by a state official to evade the well-pleaded complaint rule by seeking a declaratory judgment based on a federal defense. See Atay , 842 F.3d at 697-98.

The other cases cited by the Tribe are similarly distinguishable, because they involved either claims based on federal law or challenges to ongoing state action. See, e.g. , Bishop Paiute Tribe v. Inyo Cty. , 863 F.3d 1144, 1151-53 (9th Cir. 2017) (tribe sought a declaration that ongoing state law actions violated federal law on tribal authority to exercise jurisdiction over non-Indians); Sac & Fox Nation v. Hanson , 47 F.3d 1061, 1062 (10th Cir. 1995) (tribe sought to enjoin state court action which was itself brought under federal law).

Because there was no federal question jurisdiction, we VACATE the judgment of the district court and REMAND with instructions to dismiss for lack of subject matter jurisdiction. 
      
      Washington's attorney general was also named as a defendant. Because he was sued in his official capacity, we refer to the defendants collectively as "Washington."
     