In County Comm’rs of Franklin v. County Comm’rs of Worcester, 383 Mass. 323 (1981),2 we held that, pursuant to G. L. c. 127, § 125, as appearing in St. 1955, c. 770, § 63, a county that has borne the expense of supporting *132a prisoner sentenced directly to that county has a cause of action against the county from which the prisoner was sentenced for the purpose of obtaining reimbursement of those expenses. Following that ruling, Hampshire County recovered five judgments against Hampden County totaling $898,168.14 for supporting prisoners sentenced from Hampden County to the Hampshire County jail during the five fiscal years from July 1,1975, through June 30,1980. Executions on those judgments issued on October 29, 1982.3 To date, Hampden County has not paid or appealed the judgments.
In an effort to obtain satisfaction of the judgments, on December 31, 1982, the county commissioners of Hampshire (Hampshire County) filed this action in the Superior Court in Hampshire County, seeking to reach and apply funds due to Hampden County from the Commonwealth. These funds were due for the rental of buildings owned by Hampden County and occupied by the judicial branch of the State government. The county commissioners of Hampden and the Treasurer and Receiver General were named as defendants.4
On August 2, 1983, Hampshire County moved to amend its complaint by adding the treasurer of Hampden County and the Hampden County advisory board on county expenditures as defendants. Hampshire County also sought to add a prayer for relief in the nature of mandamus.5 The motions to amend were *133allowed on August 15, 1983. After the defendants’ answers were filed, the parties agreed that only legal issues were disputed. Accordingly, the judge treated the case as if it were before the court on a motion for summary judgment.6 See Mass. R. Civ. P. 56, 365 Mass. 824 (1974).
On August 15, 1984, a judge of the Superior Court issued a memorandum of decision, ruling in favor of Hampshire County. In his memorandum, the judge ordered the parties to “work out a plan for payment of the five judgments and executions.” The court required the parties to submit the plan by August 27, 1984, and stated that jurisdiction would be retained over the case until payment was completed.
The defendants failed to comply with the court’s order and on October 12, 1984, the court entered judgment against the defendants. From that judgment, the defendants seasonably appealed to the Appeals Court. We transferred the case to this court on our own motion.
This case requires us to consider an issue that we acknowledged but did not address in County Comm’rs of Franklin, supra, regarding the source of funds to be used to satisfy a judgment entered against a county in a case under G. L. c. 127, § 125. In Franklin, we stated that funds “might properly be available to a county to satisfy such a judgment,” but recognized that “[t]he ultimate answer must be a legislative one because of the Legislature’s control over county budgets (G. L. c. 35, §§ 32, 34).” County Comm’rs of Franklin, supra at 327 n.5. Since our decision in Franklin, amendments to G. L. c. 35, §§ 32 & 34, have effectively given control of county budgets and appropriations directly to the several counties of the Commonwealth. See St. 1981, c. 351, §§ 147 & 148, effective July 1, 1981, and June 30, 1982, respectively. Nevertheless, the defendants argue that, without an appropriation specifically for that purpose, the judgments in this case cannot be satisfied. The defendants further argue that the court cannot compel the county to make an appropriation to satisfy the outstanding judgments.
*134In County Comm’rs of Middlesex County v. Superior Court, 371 Mass. 456 (1976), we held that the commissioners of Middlesex County were obligated to pay salary increases to court stenographers as ordered by the judges of the Superior Court, “despite the lack of [a] prior appropriation.” Id. at 458. In ordering payment, we recognized that G. L. c. 35 “limits the authority of county officials to spend money in excess of appropriations.” Id. at 460. However, we also acknowledged that excess spending is permitted under certain circumstances. Id. We are not persuaded by the defendants’ attempt to distinguish the instant case from County Comm’rs of Middlesex County, supra. General Laws c. 35, § 32, second par. (1984 ed.), states that “except as otherwise provided by law, no liability may be incurred and no expenditure shall be made in excess of the amount available in an existing appropriation for a function, a main group, a class or a subclass.” (Emphasis supplied.)7 In County Comm’rs of Middlesex County, supra, we held that excess spending was permitted by the “otherwise provided by law” exception in G. L. c. 35, § 32, second par. We hold that the same exception is applicable in this case.
In County Comm’rs of Franklin v. County Comm’rs of Worcester, 383 Mass. 323 (1981), we ruled that under G. L. c. 127, § 125, “sending” counties are obligated to pay to “receiving” counties the costs expended by the latter to support the sending counties’ prisoners. Id. at 325-326. Hampshire County has obtained five valid judgments against Hampden County based upon Hampden County’s obligation under G. L. c. 127, § 125. We hold that the judgments must be paid and that the payments are permitted by G. L. c. 35, § 32, notwithstanding the absence of a prior appropriation.
The judge in the Superior Court recognized that there might be difficulty in obtaining funds to satisfy the outstanding judgments and offered the parties the opportunity to work out an agreeable payment plan. The defendants did not accept the *135judge’s offer and the judge thereafter entered an order which in essence directed the county to appropriate the money to satisfy the outstanding judgments.
The defendant county commissioners have the power under G. L. c. 35, § 30 (1984 ed.), to raise the money necessary to satisfy these judgments by levying a county tax. Such tax must be approved by the advisory board on county expenditures. § 30. This tax is apportioned and assessed among and upon the several cities and towns in the county. G. L. c. 35, § 31 (1984 ed.).
Accordingly, the defendant county commissioners are to be ordered to levy, as a county tax, the amount necessary to pay these judgments if, and to the extent that, there are no other funds available to satisfy the defendant county commissioners’ obligations.8 See G. L. c. 35, §§ 30, 32. Furthermore, the defendant Hampden County advisory board on county expenditures is to be ordered to approve such tax. G. L. c. 35, § 30.9 The judgments shall be paid promptly when funds become available.
The judgment of the Superior Court is reversed. The case is remanded to the Superior Court where a judgment shall enter in accordance with this opinion.
So ordered.