#### Sandra K. GUNDY, Plaintiff-Appellant, v. Michael J. ASTRUE, Defendant-Appellee.

No. 12-35039.

United States Court of Appeals, Ninth Circuit.

Submitted Dec. 3, 2012.*

Filed Dec. 6, 2012.

*610Charles W. Talbot, Talbot & Associates, PS, Tacoma, WA, for Plaintiff-Appellant.

Gerald James Hill, Assistant Regional Counsel, Social Security Administration Office of the General Counsel, Kerry Keefe, Esquire, Willy Le, Assistant Regional Counsel, Office of the General Counsel, Seattle, WA, for Defendant-Ap-pellee.

Before: SCHROEDER, McKEOWN, and TALLMAN, Circuit Judges.

*

 The panel unanimously concludes this case is suitable for decision without oral argument. *See*Fed. R.App. P. 34(a)(2).

MEMORANDUM **

Sandra Gundy appeals from the district court’s denial of her application for attorney’s fees under the Equal Access to Justice Act (“EAJA”), 28 U.S.C. § 2412. A prevailing party is entitled to fees under the EAJA “unless the court finds that the position of the United States was substantially justified.” *Id.*§ 2412(d)(1)(A). Gun-dy applied for the fees after we reversed the district court’s decision affirming the denial of Gundy’s application for disability benefits. *Gundy v. Astrue,*433 Fed.Appx. 595, 596-97 (9th Cir.2011).

“[I]n order to avoid a fee award the government must demonstrate the reasonableness of *both*its original action at the administrative level *and*its decision to defend that action in court.” *Flores v. Shalala,*49 F.3d 562, 570 n. 11 (9th Cir.1995) (citation omitted). These two inquiries overlap such that “the inquiry into the government’s litigation position will ordinarily encompass the inquiry into the administrative decision.” *Id.*The nature and scope of the ALJ’s legal errors are material in determining whether the Commissioner’s decision to defend them was substantially justified. *Sampson v. Chater,*103 F.3d 918, 922 (9th Cir.1996). The Commissioner’s defense of “basic and fundamental errors” will often lack substantial justification. *Corbin v. Apfel,*149 F.3d 1051, 1053 (9th Cir.1998).

We review the district court’s denial of attorney’s fees under the EAJA for abuse of discretion. *Id.*at 1052. A district court abuses its discretion when its “decision is based on an erroneous conclusion of law or when the record contains no evidence on which it rationally could have based that decision.” *Kali v. Bowen,*854 F.2d 329, 331 (9th Cir.1988) (alteration and quotation marks omitted). The district court reasoned that the government’s position was substantially justified because the ALJ had committed no error of law and because, given the conflicting medical evidence, the ALJ’s resolution was not without some rational basis. The district court also found its own (ultimately reversed) ruling upholding the ALJ’s decision to be evidence of the reasonableness of the ALJ’s determinations.

The district court permissibly considered its own holding as militating in favor of finding substantial justification. *Pierce v. Underwood,*487 U.S. 552, 568, 108 S.Ct. 2541, 101 L.Ed.2d 490 (1988). Given the subsequent reversal, however, that factor *611is inconclusive and the “merits of the Government’s litigating position” must be considered. *Id.*at 569, 108 S.Ct. 2541.

The ALJ improperly rejected the medical evidence favorable to Gundy. It is well established law in the Social Security field that “[t]o reject the opinion of a treating physician which conflicts with that of an examining physician, the ALJ must make findings setting forth specific, legitimate reasons for doing so that are based on substantial evidence in the record.” *Magallanes v. Bowen,*881 F.2d 747, 751 (9th Cir.1989) (internal quotation marks and citations omitted). The ALJ failed to articulate such reasons for rejecting the opinions of Gundy’s treating physician. *See Gundy,*433 Fed.Appx. at 596-97 (finding the ALJ’s rejection of the testimony alternately “contradicted by the record,” based on “a crabbed reading of the record,” and “belied by” multiple assessments showing significant limitations in Gundy’s daily functioning). Further, the opinion of a nonexamining physician is entitled to less weight than that of an examining physician. *Andrews v. Shalala,*53 F.3d 1035, 1041 (9th Cir.1995); *see also Lester v. Chater,*81 F.3d 821, 831 (9th Cir.1995) (“The opinion of a nonexamining physician cannot by itself constitute substantial evidence that justifies the rejection of the opinion of ... an examining physician.”). Nonetheless, the ALJ based his rejection of the opinions of two examining psychologists on a records review undertaken before and without the benefit of assessments of examining doctors. The ALJ also erred in concluding that the opinion of an examining family physician was contradicted by the assessment of a neurosurgeon where the two doctors had presented opinions on different medical issues that were not inconsistent.

To be sure, certain of the rejected opinions were disputed by other evidence. *Cf. Shafer v. Astrue,*518 F.3d 1067, 1069, 1072 (9th Cir.2008) (concluding that the government’s position was not substantially justified where ALJ rejected an uncontrovert-ed opinion without adequate explanation). However, the government’s position must be substantially justified not simply with regard to the overall disability determination, but with regard to the procedural errors on which a prevailing party wins remand. *Lewis v. Barnhart,*281 F.3d 1081, 1085 (9th Cir.2002) (“Whether the claimant is ultimately found to be disabled or not, the government’s position at each stage must be ‘substantially justified.’ ”) (alteration and internal quotation marks omitted). We conclude that the record lacks sufficient evidence on which the ALJ could have reasonably based his decision to reject the substantial medical evidence favorable to Gundy. Accordingly, the government’s defense of these procedural errors was not substantially justified. Gun-dy is therefore entitled to attorney’s fees under the EAJA.

REVERSED AND REMANDED.

**

 This disposition is not appropriate for publication and is not precedent except as provided by 9th Cir. R. 36-3.