Chief city economist Edmund Egan said married people accumulate more wealth and have more to spend on property and consumer goods, which bolsters tax revenue.
He also said the city must spend more on health care for uninsured workers because same-sex couples are not always covered under their partner's employee health care plans.
"It's clear to me that Proposition 8 has a negative material impact on the city of San Francisco," he said. "These are impacts that are hard to quantify, but over the long term they can be powerful."
Egan testified during the fourth day of a federal trial on a lawsuit challenging Proposition 8, the ballot measure approved by statewide voters in 2008.
The city was allowed to join the suit to demonstrate that governments bear some of the costs of the ban.
Egan said San Francisco has seen higher mental health costs because of discrimination against gays and now spends $2.5 million a year on specialized services for them.
"I believe that the prohibition of marriage of same-sex couples is a form of discrimination, and it's reasonable to assume that if that prohibition were removed there would be over time a lessening of the discrimination those individuals see in their daily lives," he said.
Egan acknowledged he could not quantify many of the potential revenue and savings benefits San Francisco would realize if same-sex couples could marry. The most solid estimate he cited was $2.6 million the city was losing in hotel and sales tax revenue every year from weddings that can't take place.
He based the figure on the 5,100 marriage licenses San Francisco issued to same-sex couples during a five-month period in 2008 when gay marriage was legal, as well as on wedding industry data on how much couples spend on average when they tie the knot.
"Certainly San Francisco experienced an uptake in weddings (in 2008), and I can conclude with that the economic activity associated with weddings increased as well," he said.
In addition, if same-sex couples were recognized by the federal government and could file joint income tax returns, they would realize tax savings that could be spend locally, Egan said.