The Bay Area’s top universities and their cities are quarreling — in court, as UC Berkeley faces lawsuits from elected officials and neighbors, and in City Hall, as Stanford engages in testy negotiations with Santa Clara County.

“Town and gown” tensions date back to the Middle Ages, when medieval universities first encroached on their host communities, which pushed back. The current discord — over enrollment growth, housing and whose rights are paramount — suggests little has changed over the centuries except the cash at stake: millions of dollars. Billions in Stanford’s case.

“It’s absolutely about money,” said Matthai Chakko, a spokesman for the city of Berkeley, which sued UC Berkeley on June 14.

Driving the financial disputes is the expansion of both academic titans: Stanford expecting to add nearly 10,000 students, faculty and staff in the next 17 years, while UC Berkeley already added about 9,000 students in the last 15 years — and can’t say if the trend will continue.

That’s up to the University of California regents, who haven’t told UC Berkeley what to expect, campus officials said. It’s that kind of uncertainty that has the city of Berkeley in a lather.

City officials say the campus’ long-range development plan of 2005 never warned that thousands more students — roughly the population of Emeryville, and boosting enrollment by more than a quarter — would descend on the city. As a result, the city says it’s been undercharging the university for public services, from sewer infrastructure to fire fighting.

To offset those costs, UC Berkeley pays the city either $1.4 million or $2.2 million a year, depending on whom you ask. The lower figure, provided by the city, covers the basic services it provides. UC Berkeley bumps up its figure to include expenses like paying the city to pick up students’ bulky trash when they move out at the end of the school year.

Either way, the city’s suit claims the true cost of services for 42,519 UC Berkeley students exceeds $21 million a year, up from $11 million in 2003.

And if the university grows any more, that would “almost certainly require the city to purchase new equipment and build new facilities for its police and fire departments,” says the lawsuit, which faults UC Berkeley for failing to analyze the impact of its growth on regional population and housing — or to do much about it.

“UC Berkeley, in one of the tightest housing markets in the country, has the lowest percentage of students housed of any (undergraduate) UC campus,” said Chakko, the city spokesman.

The campus housed just 22.5% of its students this year, UC records show. Only UCSF, a medical school, with no undergrads, housed students at a lower rate, 10%. Even by 2025, after several student housing projects take hold, UC Berkeley expects to house no more than 35.5% of students, still the lowest expected rate among UC’s nine undergraduate campuses.

UC Berkeley officials said they were shocked at the lawsuit, adding they thought negotiations with the city were going well.

“We have already offered to increase our payments immediately by 30%,” for an additional $660,000, campus spokesman Dan Mogulof said.

If city officials want more than that, Mogulof said, they should prove with data that they need it.

Chakko said they city has already done so. And the dispute goes on.

Town-gown disputes “generally come down to issues of resources and land use,” said Josh Yates of the University of Virginia and co-author of the “Field Guide for Urban University-Community Partnerships,” a survey of relationships at 100 universities published this year.

UC has been forced by circumstances to grow over the last several years. When the recession hit and the university responded by adding out-of-state students who pay full freight, the state’s politicians responded by insisting that UC enroll more California residents.

Stanford, by contrast, makes its own enrollment decisions. Or tries to. In Santa Clara County, Stanford and county officials are talking past each other about a massive university expansion project. The elite campus is seeking a general-use permit to build the infrastructure it would need to add 2,600 more students over two decades and to house thousands of additional faculty and staff. Campus leaders hope to increase undergraduate enrollment by nearly 25 percent, while boosting the number of graduate students by 13%.

Beyond the new beds on campus, the university is proposing to build more than 2,800 apartment units throughout the area, including 400 that are below market rate and 87 for very or extremely low-income people. The campus would also pay for transit improvements in three local cities and in San Mateo County, and would support infrastructure and academics in Palo Alto public schools.

Total cost: $4.7 billion. Square footage: 3.5 million — including 2.3 million for academic purposes.

“That’s 1½ times the size of the Empire State building,” said Joe Simitian, president of the Santa Clara County Board of Supervisors, which will decide this fall whether to grant the permit. It’s also larger than Apple’s $5 billion headquarters in Cupertino, he said, which is so large that the gym alone is 100,000 square feet.

If the project feels too big, Simitian said, the benefits to county residents feel too little.

By his calculation, the proposed billions simply don’t buy enough housing to accommodate the additional 9,610 people Stanford says will land on campus in the next 15 to 20 years.

As for the proposed price, Simitian said, “Not real. Period.” He doesn’t believe the figure because, he said, it includes hundreds of housing units that “have already been built.”

But Jean McCown, Stanford’s associate vice president for government and community relations, said she stood by the university’s numbers.

“We disagree with him on that,” she said, emphasizing that the proposed housing matches precisely to what will be needed.

One of Stanford’s frustrations is that the university hasn’t persuaded county officials to sit down with them to hash out differences face to face. Which is why, McCown said, the campus released its 52-page proposal in June. It declares the university “ready, willing and able to deliver the benefits that community stakeholders seek.”

That’s the kind of message Phil Bokovoy wishes he would hear in Berkeley. His group, Save Berkeley’s Neighborhoods, sued UC Berkeley on June 12 — the group’s third lawsuit against the campus in two years. They’re not about land use or money.

“It’s noise and activity,” Bokovoy said. “They disturb people at all hours of the day and night. And when neighbors complain, they push people away. They pretend to work with you — and when they make promises, they violate them.”

Bokovoy is closely tracking the campus’ enrollment growth, the source of the problems, he said. But he also sees a solution: an enrollment cap of the kind UC Santa Cruz agreed to in 2008.

“It’s worked well, but it’s up for renegotiation now,” he said. “Universities want to grow — but they need to pay attention to the communities in which they’re housed.”

Editor’s note: This story has been corrected. An earlier version had an incorrect percentage for the growth of Stanford’s graduate students.

Nanette Asimov is a San Francisco Chronicle staff writer. Email: nasimov@sfchronicle.com Twitter: @NanetteAsimov