                 FOR PUBLICATION

  UNITED STATES COURT OF APPEALS
       FOR THE NINTH CIRCUIT


CITY OF OAKLAND, a Municipal            No. 18-16663
Corporation, and The People of
the State of California, acting by        D.C. Nos.
and through the Oakland City         3:17-cv-06011-WHA
Attorney; CITY AND COUNTY OF         3:17-cv-06012-WHA
SAN FRANCISCO, a Municipal
Corporation, and The People of
the State of California, acting by       OPINION
and through the San Francisco
City Attorney Dennis J. Herrera,
            Plaintiffs-Appellants,

                v.

BP PLC, a public limited
company of England and Wales;
CHEVRON CORPORATION, a
Delaware corporation;
CONOCOPHILLIPS, a Delaware
corporation; EXXON MOBIL
CORPORATION, a New Jersey
corporation; ROYAL DUTCH
SHELL PLC, a public limited
company of England and Wales;
DOES, 1 through 10,
          Defendants-Appellees.
2                    CITY OF OAKLAND V. BP

         Appeal from the United States District Court
           for the Northern District of California
          William Alsup, District Judge, Presiding

            Argued and Submitted February 5, 2020
                    Pasadena, California

                        Filed May 26, 2020

        Before: Sandra S. Ikuta, Morgan Christen, and
               Kenneth K. Lee, Circuit Judges.

                      Opinion by Judge Ikuta


                           SUMMARY*


            Removal/Subject-Matter Jurisdiction

    The panel vacated the district court’s judgment and order
denying defendants’ motion to remand cases to the state court
from which they had been removed on the ground that
plaintiffs’ claim arose under federal law, and remanded for
the district court to consider whether there was an alternative
basis for subject-matter jurisdiction.

   The City of Oakland and the City and County of San
Francisco filed complaints in California state court asserting
a California public-nuisance claim against five energy
companies arising from the role of fossil fuel products in


    *
     This summary constitutes no part of the opinion of the court. It has
been prepared by court staff for the convenience of the reader.
                  CITY OF OAKLAND V. BP                      3

global warming. The complaints sought an order of
abatement requiring the energy companies to fund a climate
change adaptation program for the cities. The energy
companies removed the complaints to federal court,
identifying seven grounds for subject-matter jurisdiction,
including that the cities’ public-nuisance claim was governed
by federal common law. The district court denied the cities’
motion to remand the cases to state court, holding that it had
federal-question jurisdiction under 28 U.S.C. § 1331 because
the cities’ claim was “necessarily governed by federal
common law.” The cities amended their complaints to
include a federal nuisance claim. The district court dismissed
for failure to state a claim, and it dismissed four defendants
for lack of personal jurisdiction.

    Considering the pleadings filed at the time of removal, the
panel held that the state-law public-nuisance claim did not
arise under federal law for purposes of § 1331. The panel
explained that there is an exception to the well-pleaded
complaint rule for a claim that arises under federal law
because federal law is a necessary element of the claim. This
exception applies when a federal issue is necessarily raised,
actually disputed, substantial, and capable of resolution in
federal court without disrupting the federal-state balance
approved by Congress. The panel concluded that this
exception did not apply because the state-law claim for public
nuisance failed to raise a substantial federal question. A
second exception, referred to as the “artful-pleading
doctrine,” allows removal where federal law completely
preempts a state-law claim. The panel concluded that this
exception did not apply because the state-law claim was not
completely preempted by the Clean Air Act.
4                 CITY OF OAKLAND V. BP

     The panel further held that the cities cured any subject-
matter jurisdiction defect by amending their complaints to
assert a claim under federal common law. Thus, at the time
the district court dismissed the cities’ complaints, there was
subject-matter jurisdiction. Nonetheless, the panel held that
it could not affirm the district court’s dismissals if there was
not subject-matter jurisdiction at the time of removal. The
panel concluded that the cities did not waive their argument
in favor of remand by amending their complaints. The panel
also rejected the energy companies’ argument that any
impropriety with respect to removal could be excused by
considerations of finality, efficiency, and economy. The
panel agreed with the Fifth Circuit that a dismissal for failure
to state a claim, unlike a grant of summary judgment or
judgment after trial, is generally insufficient to forestall an
otherwise proper remand.

    The panel remanded the cases to the district court to
determine if there was an alternative basis for jurisdiction.


                         COUNSEL

Michael Rubin (argued), Barbara J. Chisholm, Rebecca
Moryl Lee, and Corinne F. Johnson, Altshuler Berzon LLP,
San Francisco, California; Victor M. Sher and Matthew K.
Edling, Sher Edling LLP, San Francisco, California; Barbara
J. Parker, City Attorney; Maria Bee, Special Counsel; Erin
Bernstein, Supervising Attorney; Malia McPherson, Deputy;
Office of the City Attorney, Oakland, California; Dennis J.
Herrera, City Attorney; Ronald P. Flynn, Chief Deputy;
Yvonne R. Meré, Chief, Complex Litigation; Matthew D.
Goldberg and Robb W. Kapla, Deputies; City Attorney’s
Office, San Francisco, California; for Plaintiffs-Appellants.
                 CITY OF OAKLAND V. BP                     5

Theodore J. Boutrous, Jr. (argued), Andrea E. Neuman, and
William E. Thomson, Gibson Dunn & Crutcher LLP, Los
Angeles, California; Joshua S. Lipshutz, Gibson Dunn &
Crutcher LLP, San Francisco, California; Neal S. Manne,
Johnny W. Carter, Erica Harris, and Steven Shepard, Susman
Godfrey LLP, Houston, Texas; Herbert J. Stern and Joel M.
Silverstein, Stern & Kilcullen LLC, Florham Park, New
Jersey; for Defendant-Appellee Chevron Corporation.

Kannon K. Shanmugam (argued), Paul Weiss Rifkind
Wharton & Garrison LLP, Washington, D.C.; Theodore V.
Wells Jr., Daniel J. Toal, and Jaren Janghorbani, Paul Weiss
Rifkind Wharton & Garrison LLP, New York, New York;
Jonathan W. Hughes, Arnold & Porter Kaye Scholer LLP,
San Francisco, California; Matthew T. Heartney and John D.
Lombardo, Arnold & Porter Kaye Scholer LLP, Los Angeles,
California; Jameson R. Jones and Sean C. Grimsley, Bartlit
Beck Herman Palenchar & Scott LLP, Denver, Colorado;
Tracie J. Renfroe and Carol M. Wood, King & Spalding LLP,
Houston, Texas; M. Randall Oppenheimer and Dawn Sestito,
O’Melveny & Myers LLP, Los Angeles, California; Daniel
B. Levin, Munger Tolles & Olson LLP, Los Angeles,
California; Jerome C. Roth and Elizabeth A. Kim, Munger
Tolles & Olson LLP, San Francisco, California; David C.
Frederick and Brendan J. Crimmins, Kellogg Hansen Todd
Figel & Frederick P.L.L.C., Washington, D.C.; for
Defendants-Appellees BP PLC, ConocoPhillips, Exxon Mobil
Corporation, and Royal Dutch Shell PLC.

Jonathan Brightbill (argued) and Eric Grant, Deputy Assistant
Attorneys General; R. Justin Smith and Christine W. Ennis,
Trial Attorneys; Environment and Natural Resources
Division, United States Department of Justice, Washington,
D.C.; for Amicus Curiae United States.
6                CITY OF OAKLAND V. BP

Michael Burger, Morningside Heights Legal Services, Inc.,
New York, New York, for Amici Curiae National League of
Cities, U.S. Conference of Mayors, and International
Municipal Lawyers Association.

Michael R. Lozeau and Richard T. Drury, Lozeau Drury LLP,
Oakland, California, for Amici Curiae Conflict of Laws and
Foreign Relations Law Scholars.

Gerson H. Smoger, Smoger & Associates P.C., Dallas, Texas;
Robert S. Peck, Center for Constitutional Litigation P.C.,
Washington, D.C.; for Amici Curiae Senators Sheldon
Whitehouse, Dianne Feinstein, Richard Blumenthal, Mazie K.
Hirono, Edward J. Markey, and Kamala D. Harris.

Seth Davis, Berkeley, California; Ruthanne M. Deutsch and
Hyland Hunt, Deutsch Hunt PLLC, Washington, D.C.; for
Amici Curiae Legal Scholars.

John W. Keker, Matthew Werdegar, and Dan Jackson, Keker
Van Nest & Peters LLP, San Francisco, California; Harold
Hongju Koh and Conor Dwyer Reynolds, Rule of Law Clinic,
Yale Law School, New Haven, Connecticut; for Amici Curiae
Former U.S. Government Officials.

James R. Williams, County Counsel; Greta S. Hansen, Chief
Assistant County Counsel; Laura S. Trice, Lead Deputy
County Counsel; Tony LoPresti, Deputy County Counsel;
Office of County Counsel, County of Santa Clara, San José,
California; for Amicus Curiae California State Association of
Counties.
                  CITY OF OAKLAND V. BP                     7

Daniel P. Mensher and Alison S. Gaffney, Keller Rohrback
L.L.P., Seattle, Washington, for Amici Curiae Robert Brulle,
Center for Climate Integrity, Justin Farrell, Benjamin Franta,
Stephan Lewandowsky, Naomi Oreskes, Geoffrey Supran,
and Union of Concerned Scientists.

Kenneth L. Adams, Adams Holcomb LLP, Washington, D.C.;
William A. Rossbach, Rossbach Law PC, Missoula,
Montana; for Amici Curiae Mario J. Molina, Michael
Oppenheimer, Bob Kopp, Friederike Otto, Susanne C. Moser,
Donald J. Wuebbles, Gary Griggs, Peter C. Frumhoff, and
Kristina Dahl.

Ian Fein, Natural Resources Defense Council, San Francisco,
California; Peter Huffman, Natural Resources Defense
Council, Washington, D.C.; for Amicus Curiae Natural
Resources Defense Council.

Xavier Becerra, Attorney General; Sally Magnani, Senior
Assistant Attorney General; David A. Zonana, Supervising
Deputy Attorney General; Erin Ganahl and Heather Leslie,
Deputy Attorneys General; Attorney General’s Office,
Sacramento, California; William Tong, Brian E. Frosh, Keith
Ellison, Gurbir S. Grewal, Letitia James, Ellen F. Rosenblum;
Peter F. Neronha, Thomas J. Donovan Jr., Robert W.
Ferguson, and Karl A. Racine, Attorneys General; for Amici
Curiae States of California, Connecticut, Maryland,
Minnesota, New Jersey, New York, Oregon, Rhode Island,
Vermont, and Washington, and the District of Columbia.

Steven P. Lehotsky, Michael B. Schon, and Jonathan D.
Urick, U.S. Chamber Litigation Center, Washington, D.C.;
Peter D. Keisler, C. Frederick Beckner III, Ryan C. Morris,
and Tobias S. Loss-Eaton, Sidley Austin LLP, Washington,
8                CITY OF OAKLAND V. BP

D.C.; for Amicus Curiae Chamber of Commerce of the
United States of America.

Corbin K. Barthold and Cory L. Andrews, Washington Legal
Foundation, Washington, D.C., for Amicus Curiae
Washington Legal Foundation.

Philip S. Goldberg and Christopher E. Appel, Shook Hardy
& Bacon LLP, Washington, D.C.; Linda E. Kelly and Peter
C. Tolsdorf, Manufacturers’ Center for Legal Action,
Washington, D.C.; for Amicus Curiae National Association
of Manufacturers.

Curtis T. Hill, Jr., Attorney General; Thomas M. Fisher,
Solicitor General; Kian J. Hudson, Deputy Solicitor General;
Julia C. Payne and Robert Rowlett, Deputy Attorneys
General; Office of the Attorney General, Indianapolis,
Indiana; Steve Marshall, Kevin G. Clarkson, Leslie Rutledge,
Christopher M. Carr, Derek Schmidt, Jeff Landry, Eric
Schmitt, Tim Fox, Doug Peterson, Wayne Stenehjem, Dave
Yost, Mike Hunter, Alan Wilson, Ken Paxton, Sean Reyes,
Patrick Morrissey, and Bridget Hill, Attorneys General; for
Amici Curiae States of Indiana, Alabama, Alaska, Arkansas,
Georgia, Kansas, Louisiana, Missouri, Montana, Nebraska,
North Dakota, Ohio, Oklahoma, South Carolina, Texas, Utah,
West Virginia, and Wyoming.

Raymond A. Cardozo and David J. de Jesus, Reed Smith
LLP, San Francisco, California; Richard A. Epstein, Chicago,
Illinois; for Amici Curiae Professors Richard A. Epstein,
Jason Scott Johnston, and Henry N. Butler.
                     CITY OF OAKLAND V. BP                             9

                             OPINION

IKUTA, Circuit Judge:

    Two California cities brought actions in state court
alleging that the defendants’ production and promotion of
fossil fuels is a public nuisance under California law, and the
defendants removed the complaints to federal court. We hold
that the state-law claim for public nuisance does not arise
under federal law for purposes of 28 U.S.C. § 1331, and we
remand to the district court to consider whether there was an
alternative basis for subject-matter jurisdiction.

                                    I

    In September 2017, the city attorneys for the City of
Oakland and the City and County of San Francisco filed
complaints in California state court asserting a California
public-nuisance claim against five of the world’s largest
energy companies:         BP p.l.c., Chevron Corporation,
ConocoPhillips, Exxon Mobil Corporation, and Royal Dutch
Shell plc.1 The complaints claim that the defendants are
liable for causing or contributing to a public nuisance under
California law. See Cal. Civ. Code §§ 3479, 3480, 3491,
3494; Cal. Civ. Proc. Code § 731. We refer to the plaintiffs
collectively as the “Cities” and to the defendants collectively
as the “Energy Companies.”



    1
       Under California law, a city attorney may bring an action to abate
a public nuisance “in the name of the people of the State of California,”
Cal. Civ. Proc. Code § 731, and so the complaints were brought in the
name of the people of the State of California, acting by and through the
city attorneys of Oakland and San Francisco.
10                CITY OF OAKLAND V. BP

    According to the complaints, the Energy Companies’
“production and promotion of massive quantities of fossil
fuels” caused or contributed to “global warming-induced sea
level rise,” leading to coastal flooding of low-lying
shorelines, increased shoreline erosion, salt-water impacts on
the Cities’ wastewater treatment systems, and interference
with stormwater infrastructure, among other injuries. The
complaints further allege that the Cities are incurring costs to
abate these harms and expect the injuries will become more
severe over the next 80 years. Accordingly, the Cities seek
an order of abatement requiring the Energy Companies to
fund a “climate change adaptation program” for Oakland and
San Francisco “consisting of the building of sea walls, raising
the elevation of low-lying property and buildings and
building such other infrastructure as is necessary for [the
Cities] to adapt to climate change.”

    In October 2017, the Energy Companies removed the
Cities’ complaints to federal court. The Energy Companies
identified seven different grounds for subject-matter
jurisdiction in their notices of removal, including that the
Cities’ public-nuisance claim was governed by federal
common law because the claim implicates “uniquely federal
                      CITY OF OAKLAND V. BP                              11

interests.”2 After removal, the cases were assigned to the
same district judge, Judge William H. Alsup.3

    The Cities moved to remand the cases to state court on the
ground that the district court lacked subject-matter
jurisdiction. The district court denied the motion, concluding
that it had federal-question jurisdiction under 28 U.S.C.
§ 1331 because the Cities’ claim was “necessarily governed
by federal common law.” The district court reasoned that the
Cities’ public-nuisance claim raised issues relating to
“interstate and international disputes implicating the
conflicting rights of States or . . . relations with foreign
nations” and that these issues had to be resolved pursuant to
a uniform federal standard.

   In response to the district court’s ruling, the Cities
amended their complaints to include a public-nuisance claim


    2
       The notice of removal also asserted that the complaints are
removable because the Cities’ claim: (1) raises disputed and substantial
federal issues, see Grable & Sons Metal Prods., Inc v. Darue Eng’g &
Mfg., 545 U.S. 308 (2005); (2) is “completely preempted” by federal law;
(3) arises out of operations on the outer Continental Shelf, see 43 U.S.C.
§ 1349(b); (4) implicates actions that the Energy Companies took
“pursuant to a federal officer’s directions,” see 28 U.S.C. § 1442(a)(1);
(5) arose on “federal enclaves”; and (6) is related to bankruptcy cases, see
28 U.S.C. §§ 1334(b), 1452(a).
    3
      Other cities and counties in California filed similar cases against the
Energy Companies and a number of other energy companies. Those cases
were filed in California state court and removed to federal court, where
they were assigned to Judge Vince G. Chhabria. Judge Chhabria
remanded those cases to state court based on a lack of subject-matter
jurisdiction. See Cty. of San Mateo v. Chevron Corp., 294 F. Supp. 3d
934, 939 (N.D. Cal. 2018). We resolve the appeal from that remand order
in a concurrently filed opinion. See Cty. of San Mateo v. Chevron Corp.,
— F.3d — (9th Cir. 2020).
12                   CITY OF OAKLAND V. BP

under federal common law.4 The amended complaints stated
that the federal claim was added “to conform to the [district
court’s] ruling” and that the Cities “reserve[d] all rights with
respect to whether jurisdiction [is] proper in federal court.”
The Energy Companies moved to dismiss the amended
complaints.

    In June 2018, the district court held that the amended
complaints failed “to state a claim upon which relief can be
granted.” Fed. R. Civ. P. 12(b)(6). The district court first
determined that it would be inappropriate to extend federal
common law to provide relief because “federal courts should
exercise great caution before fashioning federal common law
in areas touching on foreign affairs,” and the Cities’ claims
“implicate[d] the interests of countless governments, both
foreign and domestic.” The district court then dismissed the
state-law claim on the ground that it “must stand or fall under
federal common law.” The district court therefore dismissed
the amended complaints for failure to state a claim. On the
same day, the district court requested a joint statement from
the parties regarding whether it was necessary to reach the
pending motions to dismiss for lack of personal jurisdiction.
See Fed. R. Civ. P. 12(b)(2). After BP, ConocoPhillips,
Exxon, and Shell requested a ruling on the issue, the district
court ruled that it lacked personal jurisdiction over those
defendants and dismissed them. The district court then
entered judgments in favor of the Energy Companies and
against the Cities.



     4
      The Cities added the City of Oakland and the City and County of
San Francisco as plaintiffs because federal law, unlike California law,
does not allow a city attorney to bring a public-nuisance action in federal
court in the name of the people of the State of California.
                  CITY OF OAKLAND V. BP                      13

    The Cities appeal the denial of their motions to remand,
the dismissal of their complaints for failure to state a claim,
and the district court’s personal-jurisdiction ruling. We have
jurisdiction under 28 U.S.C. § 1291. We review questions of
statutory construction and subject-matter jurisdiction de novo.
Ritchey v. Upjohn Drug Co., 139 F.3d 1313, 1315 (9th Cir.
1998). “[S]tatutes extending federal jurisdiction . . . are
narrowly construed so as not to reach beyond the limits
intended by Congress.” Phillips v. Osborne, 403 F.2d 826,
828 (9th Cir. 1968).

                               II

    We first consider the Cities’ argument that the district
court erred in determining that it had federal-question
jurisdiction under 28 U.S.C. § 1331. In undertaking this
analysis, we consider only “the pleadings filed at the time of
removal without reference to subsequent amendments.”
Provincial Gov’t of Marinduque v. Placer Dome, Inc.,
582 F.3d 1083, 1085 n.1 (9th Cir. 2009) (citation omitted).

                               A

    Federal-question jurisdiction stems from a congressional
enactment, 28 U.S.C. § 1331, which provides that “[t]he
district courts shall have original jurisdiction of all civil
actions arising under the Constitution, laws, or treaties of the
United States.” The scope of this statutory grant of
jurisdiction is a matter of congressional intent, and the
Supreme Court has determined that Congress conferred “a
more limited power” than the full scope of judicial power
accorded in the Constitution. Merrell Dow Pharm. Inc. v.
14                   CITY OF OAKLAND V. BP

Thompson, 478 U.S. 804, 807 (1986).5 The general rule,
referred to as the “well-pleaded complaint rule,” is that a civil
action arises under federal law for purposes of § 1331 when
a federal question appears on the face of the complaint.
Caterpillar Inc. v. Williams, 482 U.S. 386, 392 (1987).
Because federal jurisdiction “depends solely on the plaintiff’s
claims for relief and not on anticipated defenses to those
claims,” ARCO Envtl. Remediation, L.L.C. v. Dep’t of Health
& Envtl. Quality of Mont., 213 F.3d 1108, 1113 (9th Cir.
2000), “a case may not be removed to federal court on the
basis of a federal defense, including the defense of pre-
emption, even if the defense is anticipated in the plaintiff’s
complaint, and even if both parties concede that the federal
defense is the only question truly at issue,” Caterpillar,
482 U.S. at 393. Therefore, as the “master of the claim,” the
plaintiff can generally “avoid federal jurisdiction by exclusive
reliance on state law.” Id. at 392.

    There are a few exceptions to the well-pleaded-complaint
rule, however.

                                    1

    First, in a line of cases, beginning with Northern Pacific
Railway Co. v. Soderberg, 188 U.S. 526 (1903), and
extending most recently to Grable & Sons Metal Products,


     5
       Article III of the Constitution provides that “[t]he judicial Power
shall extend to all Cases, in Law and Equity, arising under this
Constitution, the Laws of the United States, and Treaties made, or which
shall be made, under their Authority.” U.S. Const. art. III, § 2. “[T]he
constitutional meaning of ‘arising under’ may extend to all cases in which
a federal question is ‘an ingredient’ of the action.” Merrell Dow Pharm.,
478 U.S. at 807 (quoting Osborn v. Bank of U.S., 22 U.S. (9 Wheat.) 738,
823 (1824)).
                   CITY OF OAKLAND V. BP                      15

Inc. v. Darue Engineering & Manufacturing, 545 U.S. 308
(2005), the Supreme Court has recognized a “special and
small category” of state-law claims that arise under federal
law for purposes of § 1331 “because federal law is ‘a
necessary element of the . . . claim for relief.’” Empire
Healthchoice Assur., Inc. v. McVeigh, 547 U.S. 677, 699
(2006) (citation omitted). Only a few cases have fallen into
this “slim category,” id. at 701, including: (1) a series of
quiet-title actions from the early 1900s that involved disputes
as to the interpretation and application of federal law, see
Hopkins v. Walker, 244 U.S. 486, 489 (1917) (federal
jurisdiction was proper because “it [was] plain” that the case
involved “a controversy respecting the construction and effect
of” federal mining laws); Wilson Cypress Co. v. Pozo,
236 U.S. 635, 642–43 (1915) (federal jurisdiction was proper
because the plaintiffs relied “upon [a] treaty with Spain and
laws of the United States . . . to defeat [the] defendant’s claim
of title”); Soderberg, 188 U.S. at 528 (federal jurisdiction was
proper because the plaintiff’s claim“depend[ed] upon the
proper construction of an act of Congress”); (2) a shareholder
action seeking to enjoin a Missouri corporation from
investing in federal bonds on the ground that the federal act
pursuant to which the bonds were issued was
unconstitutional, see Smith v. Kan. City Title & Tr. Co.,
255 U.S. 180, 201 (1921); and (3) a state-quiet title action
claiming that property had been unlawfully seized by the
Internal Revenue Service (IRS) because the notice of the
seizure did not comply with the Internal Revenue Code, see
Grable, 545 U.S. at 311. In other cases where parties have
sought to invoke federal jurisdiction for state-law claims, the
Court has concluded that jurisdiction was lacking, even when
the claims were premised on violations of federal law, see
Merrell Dow Pharm., 478 U.S. at 805–07; Moore v.
Chesapeake & Ohio Ry. Co., 291 U.S. 205, 210 (1934),
16                CITY OF OAKLAND V. BP

required remedies “contemplated by a federal statute,”
Empire Healthchoice, 547 U.S. at 690, or required the
interpretation and application of a federal statute in a
hypothetical case underlying a legal malpractice claim, see
Gunn v. Minton, 568 U.S. 251, 259 (2013).

    The Court has articulated a test for deciding when this
exception to the well-pleaded-complaint rule applies. As
explained in Grable and later in Gunn, federal jurisdiction
over a state-law claim will lie if a federal issue is
“(1) necessarily raised, (2) actually disputed, (3) substantial,
and (4) capable of resolution in federal court without
disrupting the federal-state balance approved by Congress.”
Gunn, 568 U.S. at 258 (citing Grable, 545 U.S. at 314). All
four requirements must be met for federal jurisdiction to be
proper. Id.

    The Court has often focused on the third requirement, the
question whether a case “turn[s] on substantial questions of
federal law.” Grable, 545 U.S. at 312. This inquiry focuses
on the importance of a federal issue “to the federal system as
a whole.” Gunn, 568 U.S. at 260. An issue has such
importance when it raises substantial questions as to the
interpretation or validity of a federal statute, see Smith,
255 U.S. at 201; Hopkins, 244 U.S. at 489–90, or when it
challenges the functioning of a federal agency or program,
see Grable, 545 U.S. at 315 (holding there was federal
jurisdiction to address an action challenging the IRS’s ability
to satisfy tax delinquencies by seizing and disposing of
property); cf. Bennett v. Sw. Airlines Co., 484 F.3d 907, 911
(7th Cir. 2007) (holding that federal jurisdiction was lacking
because, among other reasons, the plaintiffs did not
“challenge the validity of any federal agency’s or employee’s
action”). Moreover, an issue may qualify as substantial when
                   CITY OF OAKLAND V. BP                       17

it is a “pure issue of law,” Empire Healthchoice, 547 U.S.
at 700 (citation omitted), that directly draws into question
“the constitutional validity of an act of Congress,” Smith,
255 U.S. at 201, or challenges the actions of a federal agency,
see Grable, 545 U.S. at 310, and a ruling on the issue is “both
dispositive of the case and would be controlling in numerous
other cases,” Empire Healthchoice, 547 U.S. at 700 (citing
Grable, 545 U.S. at 313). By contrast, a federal issue is not
substantial if it is “fact-bound and situation-specific,” see id.
at 701, or raises only a hypothetical question unlikely to
affect interpretations of federal law in the future, see Gunn,
568 U.S. at 261. A federal issue is not substantial merely
because of its novelty, see id. at 262, or because it will further
a uniform interpretation of a federal statute, see Merrell Dow
Pharm., 478 U.S. at 815–16.

                                2

    A second exception to the well-pleaded-complaint rule is
referred to as the “artful-pleading doctrine.” This doctrine
“allows removal where federal law completely preempts a
plaintiff’s state-law claim,” Rivet v. Regions Bank of La.,
522 U.S. 470, 475 (1998), meaning that “the pre-emptive
force of the statute is so ‘extraordinary’ that it ‘converts an
ordinary state common-law complaint into one stating a
federal claim for purposes of the well-pleaded complaint
rule,’” Caterpillar, 482 U.S. at 393 (quoting Metro. Life Ins.
Co. v. Taylor, 481 U.S. 58, 65 (1987)). To have this effect,
a federal statute must “provide[] the exclusive cause of action
for the claim asserted and also set forth procedures and
remedies governing that cause of action.” Beneficial Nat’l
Bank v. Anderson, 539 U.S. 1, 8 (2003).
18                CITY OF OAKLAND V. BP

    The Supreme Court has identified only three statutes that
meet this criteria: (1) § 301 of the Labor Management
Relations Act (the LMRA), 29 U.S.C. § 185, which
“displace[s] entirely any state cause of action ‘for violation of
contracts between an employer and a labor organization,’”
Franchise Tax Bd. of Cal. v. Constr. Laborers Vacation Tr.
for S. Cal., 463 U.S. 1, 23 (1983) (citation omitted);
(2) § 502(a) of the Employee Retirement Income Security Act
of 1974 (ERISA), 29 U.S.C. § 1132(a), which preempts state-
law claims asserting improper processing of a claim for
benefits under an employee-benefit plan regulation by
ERISA, Metro. Life Ins., 481 U.S. at 65–66; and (3) §§ 85
and 86 of the National Bank Act, 12 U.S.C. §§ 85, 86, which
provide the “exclusive cause of action for usury claims
against national banks,” Beneficial Nat’l Bank, 539 U.S. at 9.
In light of these cases, we have held that complete
preemption for purposes of federal jurisdiction under § 1331
exists when Congress: (1) intended to displace a state-law
cause of action, and (2) provided a substitute cause of action.
Hansen v. Grp. Health Coop., 902 F.3d 1051, 1057 (9th Cir.
2018) (citing Beneficial Nat’l Bank, 539 U.S. at 8); accord
Hunter v. United Van Lines, 746 F.2d 635, 642–43 (9th Cir.
1984).

                               B

    We now consider whether the district court erred in
concluding it had jurisdiction over the Cities’ complaints
under § 1331. At the time of removal, each complaint
asserted only a single cause of action for public nuisance
under California law. Under the well-pleaded-complaint rule,
the district court lacked federal-question jurisdiction unless
one of the two exceptions to the well-pleaded-complaint rule
applies.
                  CITY OF OAKLAND V. BP                      19

                               1

     We first consider whether the Cities’ state-law claim for
public nuisance falls within the “special and small category”
of state-law claims that arise under federal law. Empire
Healthchoice, 547 U.S. at 699. The gist of the Cities’ claim
is that the Energy Companies’ production and promotion of
fossil fuels has resulted in rising sea levels, causing harm to
the Cities. Under the Court’s test, we must determine
whether, by virtue of this claim, a federal issue is
“(1) necessarily raised, (2) actually disputed, (3) substantial,
and (4) capable of resolution in federal court without
disrupting the federal-state balance approved by Congress.”
Gunn, 568 U.S. at 258 (citing Grable, 545 U.S. at 314).

    Even assuming that the Cities’ allegations could give rise
to a cognizable claim for public nuisance under federal
common law, cf. Am. Elec. Power Co. v. Connecticut
(“AEP”), 564 U.S. 410, 423 (2011), the district court did not
have jurisdiction under § 1331 because the state-law claim for
public nuisance fails to raise a substantial federal question.
Adjudicating the claim does not require resolution of a
substantial question of federal law: the claim neither requires
an interpretation of a federal statute, cf. Grable, 545 U.S.
at 310; Hopkins, 244 U.S. at 489, nor challenges a federal
statute’s constitutionality, cf. Smith, 255 U.S. at 199. The
Energy Companies also do not identify a legal issue
necessarily raised by the claim that, if decided, will “be
controlling in numerous other cases.” Empire Healthchoice,
547 U.S. at 700 (citing Grable, 545 U.S. at 313). Indeed, it
is not clear that the claim requires an interpretation or
application of federal law at all, because the Supreme Court
has not yet determined that there is a federal common law of
public nuisance relating to interstate pollution, see AEP,
20                  CITY OF OAKLAND V. BP

564 U.S. at 423, and we have held that federal public-
nuisance claims aimed at imposing liability on energy
producers for “acting in concert to create, contribute to, and
maintain global warming” and “conspiring to mislead the
public about the science of global warming,” Native Vill. of
Kivalina v. ExxonMobil Corp., 696 F.3d 849, 854 (9th Cir.
2012), are displaced by the Clean Air Act, id. at 858.

     Rather than identify a legal issue, the Energy Companies
suggest that the Cities’ state-law claim implicates a variety of
“federal interests,” including energy policy, national security,
and foreign policy.6 The question whether the Energy
Companies can be held liable for public nuisance based on
production and promotion of the use of fossil fuels and be
required to spend billions of dollars on abatement is no doubt
an important policy question, but it does not raise a
substantial question of federal law for the purpose of
determining whether there is jurisdiction under § 1331. Cf.
Empire Healthchoice, 547 U.S. at 701 (holding that the
federal government’s “overwhelming interest in attracting
able workers to the federal workforce” and “in the health and
welfare of the federal workers upon whom it relies to carry
out its functions” was insufficient to transform a “state-court-
initiated tort litigation” into a “federal case”). Finally,
evaluation of the Cities’ claim that the Energy Companies’
activities amount to a public nuisance would require factual
determinations, and a state-law claim that is “fact-bound and
situation-specific” is not the type of claim for which federal-
question jurisdiction lies. Id.; see also Bennett, 484 F.3d at
910 (holding that federal jurisdiction was lacking when the


     6
      We do not address whether such interests may give rise to an
affirmative federal defense because such a defense is not grounds for
federal jurisdiction. See, e.g., Caterpillar, 482 U.S. at 393.
                  CITY OF OAKLAND V. BP                     21

case required “a fact-specific application of rules that come
from both federal and state law rather than a context-free
inquiry into the meaning of a federal law”).

    Given that the Cities’ state-law claim does not raise a
substantial federal issue, the claim does not fit within the
“slim category Grable exemplifies,” Empire Healthchoice,
547 U.S. at 701, and we need not consider the remaining
requirements articulated in Grable.

                              2

   The Energy Companies also argue that the Cities’ state-
law claim for public nuisance arises under federal law
because it is completely preempted by the Clean Air Act.
This argument also fails.

    The Clean Air Act is not one of the three statutes that the
Supreme Court has determined has extraordinary preemptive
force. See Ansley v. Ameriquest Mortg. Co., 340 F.3d 858,
862 (9th Cir. 2003). Rather, the Supreme Court has left open
the question whether the Clean Air Act preempts a state-law
nuisance claim under ordinary preemption principles. AEP,
564 U.S. at 429 (“In light of our holding that the Clean Air
Act displaces federal common law, the availability vel non of
a state [nuisance] lawsuit depends, inter alia, on the
preemptive effect of the federal Act.”). Nor does the Clean
Air Act meet either of the two requirements for complete
preemption. See, e.g., Hansen, 902 F.3d at 1057.

    First, the statutory language does not indicate that
Congress intended to preempt “every state law cause of
action within the scope” of the Clean Air Act. In re NOS
Commc’ns, MDL No. 1357, 495 F.3d 1052, 1058 (9th Cir.
22                   CITY OF OAKLAND V. BP

2007); see also Beneficial Nat’l Bank, 539 U.S. at 11 (holding
that federal law provides the exclusive cause of action for
usury claims against national banks such that there is “no
such thing as a state-law claim of usury against a national
bank”). Rather, the statute indicates that Congress intended
to preserve state-law causes of action pursuant to a saving
clause, 42 U.S.C. § 7416,7 which “makes clear that states
retain the right to ‘adopt or enforce’ common law standards
that apply to emissions” and preserves “[s]tate common law
standards . . . against preemption,” Merrick v. Diageo Ams.
Supply, Inc., 805 F.3d 685, 690, 691 (6th Cir. 2015) (citation
omitted). When a federal statute has a saving clause of this
sort, Congress did not intend complete preemption, because
“there would be nothing . . . to ‘save’” if Congress intended
to preempt every state cause of action within the scope of the
statute. In re NOS, 495 F.3d at 1058. Moreover, the Clean
Air Act’s statement that “air pollution control at its source is
the primary responsibility of States and local governments,”
42 U.S.C. § 7401(a)(3), weighs against a conclusion that
Congress intended to displace state-law causes of action.

   Second, the Clean Air Act does not provide the Cities
with a “substitute[]” cause of action, Hansen, 902 F.3d at
1057, that is, a cause of action that would allow the Cities to
“remedy the wrong [they] assert[] [they] suffered,” Hunter,


     7
      Section 7416 provides, “Except as otherwise provided in [statutory
exceptions not applicable here] nothing in this chapter shall preclude or
deny the right of any State or political subdivision thereof to adopt or
enforce (1) any standard or limitation respecting emissions of air
pollutants or (2) any requirement respecting control or abatement of air
pollution,” except that no state or local government may “adopt or enforce
any emission standard or limitation which is less stringent than the
standard or limitation” provided for by the Clean Air Act and its
implementing plan. 42 U.S.C. § 7416.
                  CITY OF OAKLAND V. BP                      23

746 F.2d at 643. While the Clean Air Act allows a plaintiff
to file a petition to seek judicial review of certain actions
taken by the Environmental Protection Agency, 42 U.S.C.
§ 7607(b)(1), it does not provide a federal claim or cause of
action for nuisance caused by global warming. Moreover, the
Clean Air Act’s citizen-suit provision, § 7604, permits actions
for violations of the Clean Air Act, but it does not provide the
Cities with a free-standing cause of action for nuisance that
allows for compensatory damages, see § 7604(a); Mulcahey
v. Columbia Organic Chems. Co., 29 F.3d 148, 150 & n.3
(4th Cir. 1994). Thus, the Clean Air Act satisfies neither
requirement for complete preemption.

                             ***

    In sum, because neither exception to the well-pleaded-
complaint rule applies to the Cities’ original complaints, the
district court erred in holding that it had jurisdiction under
28 U.S.C. § 1331 at the time of removal.

                              III

    Although the district court lacked jurisdiction under
28 U.S.C. § 1331 at the time of removal, that does not end
our inquiry. This is because the Cities cured any subject-
matter jurisdiction defect by amending their complaints to
assert a claim under federal common law. See Pegram v.
Herdrich, 530 U.S. 211, 215 n.2 (2000) (holding that there
was “jurisdiction regardless of the correctness of the
removal” because the “amended complaint alleged ERISA
violations, over which the federal courts have jurisdiction”);
Singh v. Am. Honda Fin. Corp., 925 F.3d 1053, 1070 (9th Cir.
2019); Retail Prop. Tr. v. United Bhd. of Carpenters &
24                    CITY OF OAKLAND V. BP

Joiners of Am., 768 F.3d 938, 949 & n.6 (9th Cir. 2014).8
Thus, at the time the district court dismissed the Cities’
complaints, there was subject-matter jurisdiction because the
operative pleadings asserted a claim “arising under” federal
common law. 28 U.S.C. § 1331. Based on this cure, the
Energy Companies raise two arguments as to why we can
affirm the district court’s dismissals, even if there was no
subject-matter jurisdiction at the time of removal.

    First, the Energy Companies argue that the Cities waived
the argument that the district court erred in refusing to
remand the cases to state court because the Cities amended
their complaints to assert a claim under federal common law.
We disagree. The Cities moved for remand and stated, in
their amended complaints, that they included a federal claim
“to conform to the [district court’s] ruling” and that they
“reserve[d] all rights with respect to whether jurisdiction is
proper in federal court.” This was sufficient to preserve the
argument that removal was improper. See Caterpillar Inc. v.
Lewis, 519 U.S. 61, 73–74 (1996); Singh, 925 F.3d at 1066.

   Second, the Energy Companies argue that any
impropriety with respect to removal can be excused because
“considerations of finality, efficiency, and economy,” Lewis,
519 U.S. at 75, weigh in favor of affirming the district court’s
dismissal of the Cities’ complaints. Again, we disagree.

    Section 1441(a) requires that a case be “fit for federal
adjudication at the time [a] removal petition is filed.” Id.

     8
      We reject the Cities’ argument that any subject-matter jurisdiction
defect was not cured because they acted involuntarily when they added a
federal claim to their complaints. Once a plaintiff asserts a federal claim,
regardless whether the plaintiff does so under protest, the district court has
subject-matter jurisdiction. Cf. Pegram, 530 U.S. at 215 n.2.
                       CITY OF OAKLAND V. BP                            25

at 73.9 Because a party violates § 1441(a) if it removes a case
that is not fit for federal adjudication, a district court
generally must remand the case to state court, even if
subsequent actions conferred subject-matter jurisdiction on
the district court. See, e.g., O’Halloran v. Univ. of Wash.,
856 F.2d 1375, 1380–81 (9th Cir. 1988) (directing a district
court to remand a complaint to state court even though the
plaintiff amended her complaint to assert violations of federal
law after the district court denied a motion to remand).

    There is, however, a narrow exception to this rule that
takes into account “considerations of finality, efficiency, and
economy.” Singh, 925 F.3d at 1065 (quoting Grupo Dataflux
v. Atlas Glob. Grp., L.P., 541 U.S. 567, 574 (2004)).
Specifically, when a jurisdictional defect has been cured after
removal and the case has been tried in federal court, a
violation of § 1441(a) can be excused if remanding the case
to state court would be inconsistent “with the fair and
unprotracted administration of justice.” Id. (quoting Lewis,
519 U.S. at 77).

    The decision to excuse a violation of § 1441(a) depends
on the stage of the underlying proceedings. When a case “has
been tried in federal court,” “considerations of finality,


    9
        Section 1441(a) provides, in relevant part:

           [A]ny civil action brought in a State court of which the
           district courts of the United States have original
           jurisdiction, may be removed by the defendant or the
           defendants, to the district court of the United States for
           the district and division embracing the place where
           such action is pending.

28 U.S.C. § 1441(a).
26                   CITY OF OAKLAND V. BP

efficiency, and economy become overwhelming,” Lewis,
519 U.S. at 75, and in those circumstances, the Supreme
Court has refused to “wipe out the adjudication
postjudgment” so long as the there was jurisdiction when the
district court entered judgment, id. at 77; see also Grubbs v.
Gen. Elec. Credit Corp., 405 U.S. 699, 702 (1972). For
instance, in Lewis, the Court excused a violation of § 1441(a)
when the case was litigated in federal court for over three
years, culminating in a six-day jury trial. 519 U.S. at 66–67.
“Requiring [remand] after years of litigation,” the Court
explained, “would impose unnecessary and wasteful burdens
on the parties, judges, and other litigants waiting for judicial
attention.” Id. at 76 (quoting Newman-Green, Inc. v. Alfonzo-
Larrain, 490 U.S. 826, 836 (1989)). We have extended this
reasoning to cases where the district court resolves “state law
issues on the merits” at summary judgment. Singh, 925 F.3d
at 1071.10 For instance, we excused a violation of § 1441(a)
when, after extensive motion practice and discovery, the
district court granted summary judgment in favor of the
defendants. Id. at 1061–62. We reasoned that the case was
sufficiently analogous to one in which there was a trial on the
merits and therefore held that “[c]onsiderations of finality,
efficiency, and economy” counseled in favor of excusing the
violation of § 1441(a). Id. at 1071 (quoting Lewis, 519 U.S.
at 75).



     10
        We have held that this rule does not apply when we reverse the
grant of summary judgment, such that there is no longer a “judgment on
the merits.” Prize Frize, Inc. v. Matrix (U.S.) Inc., 167 F.3d 1261, 1266
(9th Cir. 1999), superseded by statute on other grounds as recognized in
Abrego Abrego v. Dow Chem. Co., 443 F.3d 676, 681 (9th Cir. 2006);
accord Emard v. Hughes Aircraft Co., 153 F.3d 949, 962 (9th Cir. 1998),
abrogated on other grounds by Egelhoff v. Egelhoff ex rel. Breiner,
532 U.S. 141, 146 (2001).
                  CITY OF OAKLAND V. BP                      27

    This reasoning, however, generally will not apply when
a district court dismisses a complaint for failure to state a
claim under Rule 12(b)(6). That rule is designed “to enable
defendants to challenge the legal sufficiency of complaints
without subjecting themselves to discovery,” the cost of
which can be “prohibitive.” Rutman Wine Co. v. E. & J.
Gallo Winery, 829 F.2d 729, 738 (9th Cir. 1987). “[T]he
purpose of a motion under Rule 12(b)(6) is to test the formal
sufficiency of . . . [a] claim for relief; the motion is not a
procedure for resolving a contest between the parties about
the facts or the substantive merits of the plaintiff’s case.” 5B
Arthur R. Miller et al., Federal Practice & Procedure § 1356
(3d ed. 2020). In contrast, a motion for summary judgment
is designed to “test whether there is a genuine issue of
material fact” and “often involves the use of pleadings,
depositions, answers to interrogatories, and affidavits.” Id.
Moreover, summary judgment is appropriate only if the
“movant is entitled to judgment as a matter of law,” Fed. R.
Civ. P. 56(a), whereas “the usual course of action upon
granting a defendant’s Rule 12(b)(6) motion is to allow a
plaintiff to amend his or her complaint,” Waste Control
Specialists, LLC v. Envirocare of Tex., Inc., 199 F.3d 781,
786 (5th Cir.), opinion withdrawn and superseded in part on
reh’g, 207 F.3d 225 (5th Cir. 2000).

    In light of these differences, we agree with the Fifth
Circuit that a dismissal under Rule 12(b)(6), unlike a grant of
summary judgment, is generally “insufficient to forestall an
otherwise proper remand.” Camsoft Data Sys., Inc. v. S.
Elecs. Supply, Inc., 756 F.3d 327, 338 (5th Cir. 2014). We
have recognized that the “concern for judicial economy” is
slight when a case is pending for under a year, the plaintiff
engages in no discovery, and the district court dismisses the
case “at an early stage, prior to trial on the merits.” Dyer v.
28                   CITY OF OAKLAND V. BP

Greif Bros., 766 F.2d 398, 399, 401 (9th Cir. 1985),
superseded by statute on other grounds as stated in Beeman
v. Olson, 828 F.2d 620, 621 (9th Cir. 1987). A case
consumes a “minimum of judicial resources” if it is pending
for only a few months before it is dismissed under Rule
12(b)(6). Waste Control Specialists, 199 F.3d at 787.
Likewise, the Sixth Circuit has recognized that “concerns for
judicial economy” are insignificant when dismissal comes “so
early in the pleadings stage that there has been minimal
investment of the parties’ time in discovery or of the court’s
time in judicial proceedings or deliberations.” Chivas Prods.
Ltd. v. Owen, 864 F.2d 1280, 1286–87 (6th Cir. 1988),
abrogated on other grounds by Tafflin v. Levitt, 493 U.S. 455,
461 (1990). In short, “considerations of finality, efficiency,
and economy” are rarely, if ever, “overwhelming” when a
district court dismisses a case at the pleading stage before the
parties have engaged in discovery.11

    In this case, “considerations of finality, efficiency, and
economy” are far from “overwhelming.” Lewis, 519 U.S.
at 75. When the district court entered judgments, the cases
had been on its docket for less than a year—just over eight
months. The parties engaged in motion practice under Rule
12, and there had been no discovery. Although the district
court held hearings and the parties presented a “tutorial” on
global warming, that is a relatively modest use of judicial


     11
        In Parrino v. FHP, Inc., we held that a defendant’s failure to
comply with a judge-made procedural requirement for removal did not
warrant reversal of a dismissal under Rule 12(b)(6) and “remand of the
matter to state court.” 146 F.3d 699, 703 (9th Cir. 1998), superseded by
statute on other grounds as recognized in Abrego Abrego, 443 F.3d at
681. But Parrino is not applicable when a case is removed in violation of
§ 1441(a), resulting in a “statutory defect” with respect to removal. Grupo
Dataflux, 541 U.S. at 574.
                      CITY OF OAKLAND V. BP                              29

resources as compared to, for example, three years of
litigation, culminating in a six-day jury trial. See id. at
66–67. Because the district court dismissed these cases at the
pleading stage, after they were pending for less than a year
and before the parties engaged in discovery, we conclude that
“considerations of finality, efficiency, and economy” are not
“overwhelming.” Id. at 75; see Camsoft Data Sys., 756 F.3d
at 338; Waste Control Specialists, 199 F.3d at 786; Dyer,
766 F.2d at 401; Chivas Prods., 864 F.2d at 1286–87.
Accordingly, if there was not subject-matter jurisdiction at
the time of removal, the cases must proceed in state court.

                                    IV

    The district court did not address the alternative bases for
removal asserted in the Energy Companies’ notices of
removal. And we generally do not consider issues “not
passed upon below.” Am. President Lines, Ltd. v. Int’l
Longshore & Warehouse Union, Alaska Longshore Div., Unit
60, 721 F.3d 1147, 1157 (9th Cir. 2013) (quoting Singleton v.
Wulff, 428 U.S. 106, 120 (1976)). Accordingly, we remand
these cases to the district court to determine whether there
was an alternative basis for jurisdiction.12 If there was not,


    12
        The district court requested supplemental briefing on how the
concept of the “‘navigable waters of the United States’ . . . relates to the
removal jurisdiction issue in th[e] case.” As the Cities pointed out,
however, the Energy Companies waived any argument related to admiralty
jurisdiction by not invoking it in their notices of removal. See 28 U.S.C.
§ 1446(a) (notice of removal must “contain[] a short and plain statement
of the grounds for removal”); ARCO, 213 F.3d at 1117 (notice of removal
“cannot be amended to add a separate basis for removal jurisdiction after
the thirty day period” (citation omitted)); O’Halloran, 856 F.2d at 1381
(same). Thus, the district court should confine its analysis to the bases for
jurisdiction asserted in the notices of removal.
30                      CITY OF OAKLAND V. BP

the cases should be remanded to state court.13 This panel will
retain jurisdiction for any subsequent appeals arising from
these cases.

     VACATED AND REMANDED.14




     13
        We do not reach the question whether the district court lacked
personal jurisdiction over four of the defendants. If, on remand, the
district court determines that the cases must proceed in state court, the
Cities are free to move the district court to vacate its personal-jurisdiction
ruling. Cf. Ruhrgas AG v. Marathon Oil Co., 526 U.S. 574, 587–88
(1999) (stating that in most instances “expedition and sensitivity to state
courts’ coequal stature should impel [a] federal court to dispose of
[subject-matter jurisdiction] issue[s] first”); Cerner Middle E. Ltd. v.
Belbadi Enters. LLC, 939 F.3d 1009, 1014 (9th Cir. 2019) (holding that
the case should be remanded to state court based on a lack of subject-
matter jurisdiction and declining to reach the issue of personal
jurisdiction); Special Invs., Inc. v. Aero Air, Inc., 360 F.3d 989, 994–95
(9th Cir. 2004).
     14
          Each party shall bear its own costs on appeal.
