SAN JOSE — The fight between San Jose and Santa Clara County over $40 million in tax dollars is finally settled — and San Jose just got a little bit richer.

The California Supreme Court last week denied the county’s appeal to keep the money which came from a property tax, ending a four-year legal battle between the county and its largest city. San Jose had received a portion of the tax revenue — about $7 million a year — to pay for costs related to winding down its redevelopment agency.

But the county began withholding the money from San Jose in 2012, arguing the revenue was earmarked to fund county employees’ retirement plans through CalPERS. After losing two court cases, the county appealed to the state’s highest court which chose not to hear the case last week, allowing the lower court rulings to stand.

In its case, the county argued that giving the $40 million to San Jose would be a “prohibited gift of public funds,” and not using it for retirement violates county employees’ vested rights. Both arguments were rejected by the court, according to legal papers.

San Jose will likely receive about $20 million from the pot of money, city leaders said, because some is funneled to pay for other obligations.

“We always thought it was a novel theory on the part of the county,” said San Jose City Attorney Rick Doyle. “It’s always unfortunate to be fighting over tax money when 50 percent of the county’s residents are San Jose residents. Everybody has an incentive to settle it and move on.”

County Counsel James Williams was unavailable for comment.

Doyle said San Jose will use the money to reimburse the city’s general fund which paid for administrative costs related to the redevelopment agency’s successor agency and bonds on the Convention Center and the Fourth Street Garage — which could’ve been paid by the tax revenue.

“We had our debts to pay and by withholding the money, they burdened the city’s general fund to pay those debts,” he said.

The tax in recent years has been 33.8 cents for every $1,000 of assessed property value.

Former San Jose Councilman Pierluigi Oliverio, who publicly fought to settle the suit, applauded the California Supreme Court’s decision to reject the county’s appeal. San Jose in 2012 offered to end litigation and to allow the county to spend the disputed money on housing for the poor — but the county refused.

“It’s a shame the county insisted on litigation,” Oliverio said.