HUG, Circuit Judge:
After prevailing in a tax refund suit, appellants sought recovery of attorneys’ fees under the Equal Access to Justice Act. The district court denied the fee request on the basis that the Government’s position in defending the suit was substantially justified. We conclude the Government’s position was not substantially justified and therefore reverse and remand for determination of the fee award.
Appellants include an individual, Timms, and several related entities that market gasoline through self-service stations. Starting in 1970, appellants took the position that for federal tax purposes the operators of their stations were not employees, but independent contractors. Accordingly, appellants did not withhold or remit to the Government federal employment taxes for those individuals for the period 1970-1976. Following an audit, the Internal Revenue Service disagreed with that classification and assessed a tax. Appellants paid an initial installment on the assessment and then filed a district court action for a refund.
In January 1978, appellants offered to settle their refund claim. In an agreement reached under I.R.C. § 7122, appellants agreed to withhold and remit employment taxes on station operators as of January 1, 1977. They agreed to pay the deficiency assessed for the period 1970-1976 by making a down payment of $365,000 and paying the balance over a 30-month period. The agreement also provided in paragraph 7:
that in the event that the Internal Revenue Code or any official governmental interpretation thereof is amended to treat such or similar individuals as independent contractors and not as employees, then as of and after the effective date of any such change in the Internal Revenue Code or in any official governmental interpretation thereof, taxpayers will not be required to comply with Federal income tax withholding, FICA or FUTA provisions in regard to the service station operators and/or area managers employed by them as of and after such effective date and will be entitled to appropriate refunds if such changes are given retroactive effect.
Appellants began to make monthly payments but had not paid off the balance when Congress enacted section 530 of the Revenue Act of 1978, I.R.C. § 3401 note (Controversies Involving Whether Individuals are Employees for Purposes of Employment Taxes). Section 530 provided that if an employer did not treat an individual as an employee for any period prior to January 1, 1980, and if that treatment was reasonable, the individual would be deemed not to be an employee. The statute also allowed a refund or credit in the case of overpayment of an employment tax where such a refund was not barred “by any law or rule of law.”
The Government agreed that section 530 relieved appellants of the obligation to pay the balance due under the compromise agreement and allowed them to treat station operators as independent contractors in the future. However, it refused appellants’ demand for a refund of amounts previously paid to cover the deficiency for 1970-1976. Appellants then filed a refund action in the district court to recover the amounts paid for the 1970-1976 deficiency. (They did not at that time file for a refund of the amounts paid in 1977 and 1978.) They claimed section 530 constituted a change in the Internal Revenue Code that entitled them to a refund under paragraph 7 of the compromise agreement. The Government opposed this claim on two grounds. First, it contended section 530 did not permit any refund of any amounts paid pursuant to a compromise agreement, even where the written compromise purported to authorize a refund. Second, it argued that, assuming paragraph 7 of the agreement did authorize a refund, it applied only to periods after January 1, 1977.
The district court rejected both of the Government’s contentions and ordered a refund. On appeal, this court reviewed the Government’s alternate theories. Timms v. United States, 678 F.2d 831 (9th Cir. 1982) (“Timms I”). Although we rejected the first theory, id. at 833-34, we agreed with the Government’s alternate claim, concluding that paragraph 7 of the agreement concerned only payments made for tax years after 1976 and that therefore the refund provision of paragraph 7 authorized refunds only for the years after 1976. Id. at 835.
After the Government had appealed Timms I, but before this court issued its decision, appellants filed the instant action, Timms II They sought a refund of $35,-963.14, plus interest, to cover employment taxes paid for 1977 and 1978. The Government opposed this claim by reasserting its first defense in Timms I — the contention that section 530 precluded any refund of amounts paid pursuant to a compromise agreement. However, shortly after this court’s decision in Timms I was issued, the Government conceded liability for a refund of the 1977-1978 taxes. Appellants then moved under the Equal Access to Justice Act (“EAJA”), 28 U.S.C. § 2412, to recover costs and attorneys’ fees for Timms II. The district court denied the fee request.
Section 2412(d)(1)(A) of EAJA directs the district court to award attorneys’ fees to the prevailing party unless it finds that the position of the United States was substantially justified. Several other circuits have disagreed as to whether the “position” that must be justified is the underlying agency action or the legal position of the United States during litigation. Hoang Ha v. Sckweiker, 707 F.2d 1104, 1105 (9th Cir.1983); see also Spencer v. NLRB, 712 F.2d 539, 557 (D.C.Cir.1983), cert. denied, — U.S. —, 104 S.Ct. 1908, 80 L.Ed.2d 457 (1984); Natural Resources Defense Council, Inc. v. EPA, 703 F.2d 700, 707 (3d Cir.1983); Tyler Business Services, Inc. v. NLRB, 695 F.2d 73, 75 (4th Cir.1982); Broad Avenue Laundry & Tailoring v. United States, 693 F.2d 1387, 1390-91 (Fed.Cir.1982). We have determined that the remedial purpose of EAJA is best effectuated if we consider the totality of the circumstances present prior to and during litigation. Rawlings v. Heckler, 725 F.2d 1192, 1196 (9th Cir.1984). In this case, there is no challenge to the Government’s prelitigation conduct. We therefore need only review the district court’s determination that the Government’s litigation position in this case was “substantially justified.”
This statutory term describes a position that has a reasonable basis both in law and in fact. Wolverton v. Heckler, 726 F.2d 580, 583 (9th Cir.1984); Hoang Ha, 707 F.2d at 1106; Foster v. Tourtellotte, 704 F.2d 1109, 1112 (9th Cir.1983). The Government bears the burden of proving its position was substantially justified. H.R.Conf.Rep. No. 1434, 96th Cong., 2d Sess. 15, reprinted in 1980 U.S.Code Cong. & Ad.News 5003, 5011. It may carry that burden by showing its position advanced “a novel but credible extension or interpretation of the law.” Hoang Ha, 707 F.2d at 1106; see Foster, 704 F.2d at 1112-13. The fact that the Government lost its case on the merits does not create a presumption that its position was not substantially justified. H.R.Rep. 1418, 96th Cong., 2d Sess. 11, reprinted in 1980 U.S.Code Cong. & Ad.News 4984, 4990.
In concluding that the Government satisfied these standards, the district court reasoned that the central question in Timms II was the proper interpretation of the compromise agreement, a matter which remained unresolved until our decision in Timms I. The court believed the interpretation proposed by the Government was reasonable. Under the standard adopted in prior cases, we review this determination for an abuse of discretion. United States v. First National Bank of Circle, 732 F.2d 1444, 1446 (9th Cir.1984); Rawlings, 725 F.2d at 1196.
The Government’s position in this litigation was that section 530 of the Revenue Act of 1978 did not permit a refund of amounts paid on a compromised claim. It reasoned that section 530 permitted a refund only if it was not barred by any law. The law applicable to compromised claims is I.R.C. § 7122, under which the compromise is generally considered to be final and thus not subject to a refund. Timms I, 678 F.2d at 833; see 26 C.F.R. § 301.7122-l(c) (1981). The Government assumed that general rule would apply to the compromise of claims regarding employment status. It relied on the legislative history of the Act, which provided in part:
Taxpayers who have entered into final closing agreements under Code section 7121 or compromises under section 7122 with respect to employment status controversies are ineligible for relief under the bill, unless they have not completely paid their liability. Thus, for example, a taxpayer who has agreed or compromised a liability for an amount which is to be paid in installments, but who still has one or more installments to pay, is relieved of liability for such outstanding installments.
H.R.Rep. No. 1748, 95th Cong., 2d Sess. 6 (1978), 1978-3 (vol. 2) C.B. 629, 634.
In Timms I, we characterized this interpretation of the statute as “patently erroneous.” Timms I, 678 F.2d at 833. We conceded that a taxpayer who entered into an ordinary compromise agreement under I.R.C. § 7122 would not be eligible for a refund, based on the language of section 530 and its legislative history. Id. However, we emphasized that in appellants’ case the Government had contracted to provide a refund in the event the law changed in appellants’ favor. We pointed to the Government’s obvious obligation to abide by the terms of agreements it enters into with taxpayers. In view of our analysis in Timms I, we cannot say the Government’s claim that it had no duty to satisfy its contractual obligations to appellants had a reasonable basis in law. We therefore conclude that the district court abused its discretion in denying the appellants an award of attorneys’ fees.
The Government’s contention that appellants’ recovery must be limited to services performed after October 1, 1981 is without merit. See Wolverton, 726 F.2d at 583; Rawlings, 725 F.2d at 1194-95. On remand, the district court shall determine the proper amount of the award as provided by 28 U.S.C. § 2412(d)(2).
REVERSED and REMANDED.