SAN JOSE — A four-year court battle between San Jose and Santa Clara County over $40 million in property taxes might soon be decided by the state’s highest court, settling a longstanding dispute over which government agency gets to keep the cash.

City leaders say the money belongs to San Jose for its redevelopment costs and sued Santa Clara County in 2012 for refusing to turn it over. The county counter-sued, saying the money was earmarked for county retirement obligations, but lost in two separate rulings, including a recent decision from an appeals court.

Now the county is appealing to the California Supreme Court, setting off an unusual feud between two local governments vying for much-needed revenue in wealthy Silicon Valley.

The money comes from a special property tax voters approved in 1944 to fund the county’s retirement obligations. However, it applied differently in redevelopment areas, established to revitalize areas in need of urban renewal. Redevelopment efforts were funded from the increases in tax revenue as property values rose in project areas, known as “tax increment.”

San Jose’s redevelopment agency, established in 1956, was receiving about $7 million a year from the additional tax levy.

But when state officials abolished redevelopment agencies in 2012, citing concerns that they were diverting too much property tax revenue from basic government services, Santa Clara County withheld the revenue from San Jose.

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

“San Jose always got the money up until the termination of the redevelopment agencies,” said City Attorney Rick Doyle. “After 50 years of never raising the issue, all of a sudden it came up one day. The county wrongfully withheld the money, and their interpretation is wrong.”

County Counsel James Williams declined comment, citing pending litigation.

In legal papers, the county argued the retirement levy is a “special tax” that can only be used for a specific purpose — in this case to fund county employees’ retirement plans through CalPERS — and San Jose isn’t entitled to the money after redevelopment agencies went away. The funds were helping San Jose pay off redevelopment agency bonds.

But the appellate court did not agree with the county, backing the ruling of a lower trial court.

“Nothing in the law concerning special taxes prohibits distribution of the tax increment portion of the retirement levy to the successor agency to pay the former redevelopment agency’s debts,” according to a November decision from the Court of Appeal in the Third Appellate District.

The county also 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.

But the court found San Jose is only entitled to use the money to pay off the former redevelopment agency’s bond debt — not any other debt. The city appealed on that point.

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 shows the county’s continued uncooperative stance when it comes to solving litigation between the city and the county,” said Councilman Pierluigi Oliverio, who has publicly fought to settle the suit. “This money could go to low-income housing; however, the county continues to appeal.”

Doyle said the county’s decision to withhold the money from San Jose has “damaged” the city. It’s caused San Jose to spend general fund dollars to pay bonds on the Convention Center and the Fourth Street Garage — which could’ve been paid by the tax revenue.

San Jose also paid for administrative costs related to the successor agency, including staff hours, to the tune of $10 million over six years, Doyle said. If the county hands the money over to San Jose, Doyle said it’ll be used to reimburse the city’s general fund.

The California Supreme Court should decide whether to hear the case by mid-February. If it declines to hear the case, the appellate ruling against the county would stand.