                     FOR PUBLICATION
  UNITED STATES COURT OF APPEALS
       FOR THE NINTH CIRCUIT

WESTERN WATERSHEDS PROJECT,                
                Plaintiff-Appellant,
                v.                                No. 11-35464
STEVE ELLIS, Director, Idaho State                  D.C. No.
                                               1:04-cv-00181-BLW
Office, Bureau of Land
Management; RICK VANDER VOET;                       OPINION
BUREAU OF LAND MANAGEMENT,
             Defendants-Appellees.
                                           
        Appeal from the United States District Court
                  for the District of Idaho
      B. Lynn Winmill, Chief District Judge, Presiding

                   Argued and Submitted
            August 27, 2012—Seattle, Washington

                      Filed October 9, 2012

     Before: Mary M. Schroeder and Ronald M. Gould,
 Circuit Judges, and Jed S. Rakoff, Senior District Judge.*

                   Opinion by Judge Schroeder




   *The Honorable Jed S. Rakoff, Senior United States District Judge for
the Southern District of New York, sitting by designation.

                                12219
             WESTERN WATERSHEDS PROJECT v. ELLIS          12221




                         COUNSEL

Todd C. Tucci, Boise, Idaho, for plaintiff-appellant Western
Watersheds Project.

Syrena C. Hargrove, Assistant United States Attorney, Boise,
Idaho, for defendants-appellees Steve Ellis, Director of Idaho
Bureau of Land Management, et al.


                          OPINION

SCHROEDER, Circuit Judge:

   This appeal involves an attorneys’ fee dispute that added a
rancorous coda to long-running grazing permit litigation in
Idaho that was all ably overseen by the district court. The
plaintiff, Western Watersheds Project (“WWP”), originally
filed this action in 2004 challenging the Bureau of Land Man-
agement’s (“BLM”) renewal of grazing permits in the Jar-
bidge Resource Area (“JRA”), covering a large expanse of
Southern Idaho. In 2005, the district court ruled in a published
opinion that WWP’s challenge had merit and that the BLM
had violated federal statutes by inadequately protecting habi-
tat of threatened, endangered, or sensitive species. See West-
12222        WESTERN WATERSHEDS PROJECT v. ELLIS
ern Watersheds Project v. Bennett (WWP I), 392 F. Supp. 2d
1217, 1227-29 (D. Idaho 2005).

   The parties in 2006 entered into what they thought was a
settlement of the entire dispute, but in July of 2007 a massive
fire changed the situation dramatically. The BLM then
allowed grazing on unburned areas to continue, and after tak-
ing several months to regroup, began issuing new grazing
authorizations. WWP successfully challenged the post-fire
grazing decisions and authorizations as inadequately protect-
ing wildlife habitat, but the district court denied WWP’s claim
for fees, and this appeal followed. The issue before us is thus
whether the district court erred in denying plaintiff WWP fees
under the Equal Access to Justice Act (“EAJA”), 28 U.S.C.
§ 2412(d)(1)(A).

   WWP’s position is that the district court considered only
the reasonableness of the underlying agency decision to issue
grazing authorizations after the fire, and did not adequately
consider the reasonableness of the litigation strategy defend-
ing that decision. Our review of the record convinces us that
the district court did consider both factors, and we affirm.

   FACTUAL AND PROCEDURAL BACKGROUND

   The background of the dispute is more fully explained in
the district court’s 2005 opinion. WWP I, 392 F. Supp. 2d at
1220-1222. The BLM has divided the public lands it manages
into administrative segments it calls Resource Areas. See 43
C.F.R. § 1601.0-5. Each Resource Area is required to have a
Resource Management Plan (“RMP”). See 43 U.S.C.
§§ 1701-84; see also 43 C.F.R. § 1610.1(b). The BLM has
managed the Jarbidge Resource Area, an area of approxi-
mately 1.7 million acres of land in Southern Idaho, pursuant
to the RMP completed in 1987. A key issue in managing the
JRA has been preventing further environmental deterioration
caused by excessive grazing. A related concern has been dam-
age to the habitat for listed species and candidates for listing
            WESTERN WATERSHEDS PROJECT v. ELLIS          12223
under environmental statutes like the Endangered Species
Act. Of particular concern have been the habitats for the sage
grouse and pygmy rabbit, species whose numbers have dra-
matically declined during the last century.

   In 2004, WWP challenged the BLM’s renewal of grazing
permits for 28 of the allotments managed under the 1987 plan.
WWP contended that the permits conflicted with the RMP’s
provisions to protect wildlife habitat. The BLM responded
that such provisions were aspirational rather than mandatory.
The district court ruled otherwise, holding that the provisions
spoke “in terms of requirements, not suggestions.” WWP I,
392 F. Supp. 2d at 1227. The district court enjoined grazing
on the challenged allotments pending the BLM’s completion
of a new environmental analysis. These rulings are not at
issue here.

   The 2005 rulings resulted in the parties forming their Set-
tlement Agreement. It established interim grazing restrictions
that were to apply during the time frame the Agreement set
for the BLM to complete a new RMP for the Jarbidge Area,
together with a supporting Environmental Impact Statement.
The Settlement Agreement also contemplated that the new
RMP would be completed in 2009. The Settlement Agree-
ment resolved all of the issues concerning attorneys’ fees and
costs up through that stage of the litigation.

  All these well-laid plans were frustrated, however, when a
massive wildfire, termed by the district court “catastrophic,”
swept through the area in 2007. The fire, known as the Mur-
phy Complex Fire, burned more than 400,000 acres, destroy-
ing most of the known pygmy rabbit habitat and sage grouse
nesting habitat. It also destroyed much of the grazing land.

  In early 2008 the BLM began issuing authorizations for
grazing on the unburned areas. The fire’s habitat destruction
and the new grazing authorizations caused WWP to file a
motion to reopen the litigation in order to seek an injunction
12224        WESTERN WATERSHEDS PROJECT v. ELLIS
against grazing on many of the remaining unburned allot-
ments. Although the district court declined to alter the permits
covered by the Agreement, it ruled in favor of WWP with
respect to the remaining allotments. The district court held
that the government had to reduce the grazing in the unburned
areas to provide needed wildlife habitat. The court observed,
however, that the government would act in good faith to
reduce grazing and therefore denied as unnecessary WWP’s
request for a formal injunction against all grazing pending the
required reexamination of the grazing authorizations.

   None of those 2009 district court rulings are at issue in this
appeal. What is at issue is WWP’s subsequent motion for
attorneys’ fees as the prevailing party. Under the EAJA, a pre-
vailing party is generally entitled to fees against the govern-
ment unless the position of the government was substantially
justified. 28 U.S.C. § 2412(d)(1)(A); see Gonzales v. Free
Speech Coalition, 408 F.3d 613, 618 (9th Cir. 2005). The dis-
trict court denied WWP attorneys’ fees and WWP appeals,
contending the district court ignored one of the factors it was
required to consider in determining whether the government’s
position in this case was substantially justified.

                        DISCUSSION

   [1] In an action brought by or against the United States, the
EAJA requires the court to award fees and costs to the “pre-
vailing party other than the United States . . . unless the court
finds that the position of the United States was substantially
justified or that special circumstances make an award unjust.”
28 U.S.C. § 2412(d)(1)(A). In determining whether the posi-
tion of the United States was substantially justified under the
EAJA, a court must look “both to the government’s position
during litigation and to ‘the action or failure to act by the
agency upon which the civil action is based.’ ” United States
v. Marolf, 277 F.3d 1156, 1161 (9th Cir. 2002) (quoting 28
U.S.C. § 2412(d)(1)(B)). A position is substantially justified
if it has a “reasonable basis in both law and fact.” Id. The
             WESTERN WATERSHEDS PROJECT v. ELLIS           12225
government has the burden to show that its position was sub-
stantially justified. Id. (citing Gutierrez v. Barnhart, 274 F.3d
1255, 1258 (9th Cir. 2001)). In this case, the underlying
action is the post-fire decision to allow grazing in the
unburned areas. WWP argued that in taking this action, the
BLM ignored the district court’s earlier ruling that habitat
preservation was mandatory.

  In denying fees for the post-fire litigation, the district court
gave the following explanation:

    BLM was doing the best it could in this dire situa-
    tion. While the BLM was committing the same error
    in interpretation after the fire as it did before, its
    post-fire error was the result of managers scrambling
    to salvage something from a disaster, and was not a
    blatant disregard of the [c]ourt’s prior decision. . . .
    The landscape had so changed that a reasonable
    argument could be made to support the BLM’s man-
    agement, even if that argument ultimately proved
    unsuccessful.

   WWP now argues that the district court did not evaluate the
reasonableness of BLM’s litigation position, defending the
grazing authorizations, when the court denied WWP’s motion
for fees. WWP points to the district court’s description of the
changed landscape and asserts that the district court consid-
ered only the underlying decision of the BLM to authorize
grazing in the unburned areas, but not its subsequent litigation
position defending that strategy.

   [2] The district court’s opinion, however, refers not only to
the unexpected events that led to the agency grazing decision,
but also the reasonableness of defending that decision. In the
briefing to the district court on the fee issue, both parties
acknowledged the need for the court to consider the underly-
ing agency decision as well as its position in the litigation.
The district court stated that “a reasonable argument could be
12226       WESTERN WATERSHEDS PROJECT v. ELLIS
made to support the BLM’s management, even if that argu-
ment ultimately proved unsuccessful.” The “unsuccessful”
argument was the one made during the post-fire litigation.

   The district court’s explanation addressed WWP’s principal
argument that the BLM was attempting to defend an interpre-
tation of the RMP that the district court had rejected in its
2005 opinion. In the district court, WWP’s attack on both the
underlying agency decision and its litigation strategy had the
same focus. WWP’s argument did not separate the litigation
strategy from the grazing decision. We therefore cannot fault
the district court for not parsing WWP’s argument in the way
that WWP asks us to do in this appeal.

   [3] WWP stated before the district court that neither the
underlying actions nor the litigation position could be sub-
stantially justified because the BLM was “again misreading
the RMP,” just as it had in the 2005 litigation. The district
court, in rejecting the BLM’s post-fire position, explained in
meticulous detail how conditions had changed dramatically
due to the fire. Its 2009 decision made 255 total findings of
fact, including 21 separate findings of fact on the effects of
the Murphy Complex Fire. The district court agreed with
WWP that the BLM had made the same error in interpreta-
tion, but said BLM was not “blatant[ly] disregard[ing] [ ] the
[c]ourt’s prior decision.” Rather it was “scrambling to salvage
something from a disaster.” The record supports this evalua-
tion. There was no abuse of discretion in denying fees.

  AFFIRMED.
