Two San Francisco tech moguls worth $12 billion between them got into a heated exchange of tweets Friday over a city ballot measure aimed at ending homelessness.

Jack Dorsey, the head of Square and Twitter, took to the social app he runs to express his opposition to Proposition C, drawing ire from its most vocal supporter, Salesforce chief Marc Benioff.

Prop. C, which appears on the Nov. 6 ballot, would tax the biggest businesses in San Francisco to raise as much as $300 million for homeless programs.

Benioff on Monday came out strong for Prop. C, pledging at least $2 million of company money and his personal fortune to help pass the initiative.

“I want to help fix the homeless problem in SF and California. I don’t believe this (Prop C) is the best way to do it,” Dorsey tweeted, including a link to an earlier tweet by Benioff about his own support for the measure.

Benioff responded: “Hi Jack. Thanks for the feedback. Which homeless programs in our city are you supporting?”

The Salesforce co-CEO then asked Dorsey on Twitter how much money he’s donated to the $37 million, 2-year-old Hamilton Families Heading Home Campaign, which Benioff helped start with the city for housing homeless families. The program has housed nearly 400 families through rent subsidies.

Benioff noted Dorsey’s estimated net worth of $6 billion — Benioff’s fortune is believed to be around that range as well — and asked how much he has given.

“Exactly (how) much have his companies & personally given back to our city, our homeless programs, public hospitals, & public schools?” Benioff tweeted.

Several hours later, Dorsey responded: “Marc: you’re distracting. This is about me supporting Mayor @LondonBreed for *the* reason she was elected. The Mayor doesn’t support Prop C, and we should listen to her.”

The exchange seemed heated, but Benioff says he and Dorsey are friends.

“My reaction was that this was giving me a great opportunity to tell my story,” Benioff said. Of Dorsey, he said, “I just saw him at the Warriors finals. If you can’t ask your friends hard questions, are you really friends?”

Benioff, who has donated millions of dollars to house homeless families and strongly advocated for more street programs, told The Chronicle on Monday that the only way to significantly reduce the crisis of 7,500 individuals and 1,200 families languishing in the streets is to scale up government spending. Prop. C would generate an amount of funding that about doubles what San Francisco already spends to assist homeless people and keep them housed.

After announcing his support, celebrities including Chris Rock, Jewel and William James Adams Jr., known professionally as Will.i.am, rallied around Benioff on Twitter.

Photo: Drew Angerer / Getty Images Photo: Gabrielle Lurie / The Chronicle 2018 Photo: Gabrielle Lurie / The Chronicle Photo: Newspix / Getty Images Photo: Gabrielle Lurie / The Chronicle

Opposition to Prop. C picked up momentum in October when Breed, state Sen. Scott Wiener, D-San Francisco, and Assemblyman David Chiu, D-San Francisco, said in statements that there isn’t enough accountability in the measure to ensure funds would be properly spent. But Benioff, whose Salesforce is the city’s largest private employer and projects approximately $13 billion in revenue this year, said he thinks he can persuade other big-business leaders to show support.

On Twitter, Dorsey said he supported Breed and Wiener’s stance on the issue, as well as their “commitment” to addressing the homelessness crisis “in the right way.”

“Mayor Breed was elected to fix this,” Dorsey tweeted. “I trust her.”

Benioff said Breed had called him Friday to discuss the prospect of him giving $8 million personally to fund a homeless shelter. The mayor’s office said there had been discussion but would not confirm details.

In response to Dorsey’s original tweet, more than 100 people posted replies to criticize his position. Some people called into question the tech billionaire’s motives for opposition.

Also known as the “Our City, Our Home” initiative, Prop. C would impose an additional gross receipts tax of about 0.5 percent on corporate revenue above $50 million. A report by the city’s Office of Economic Analysis concluded that 300 to 400 of the largest businesses in San Francisco would pay the tax.

A payroll tax break for companies in the Mid-Market area known as the “Twitter tax break” is set to expire in May. While Twitter has taken advantage of that break on the payroll tax — a fact Benioff pointed out on Twitter — Square, which is outside of the designated area, has not.

Twitter declined to comment.

A Square spokesman noted that a quirk of the gross receipts tax could disproportionately harm it and other San Francisco payments companies like Stripe. When a retailer uses Square to process a credit card transaction, Square collects a 2.75 percent fee. For a given sale, San Francisco could collect the gross receipts tax twice — on the original purchase and on Square’s fee.

“Homelessness in San Francisco is a humanitarian crisis,” Square said. “We are eager to collaborate with City Hall, local organizations, other businesses on a unified approach to this issue. Prop. C is not that approach.”

Greg La Blanc, a lecturer at UC Berkeley’s Haas School of Business, said he can understand why San Francisco companies that process lots of transactions, like Airbnb or Square, are worried about the implications of the tax.

Those companies have “taken the risk of locating in that area and planting their flag right smack in the middle of all these homeless people,” said La Blanc. Square may “see themselves as a target” if the city moves to tax its biggest businesses to “take care of this” issue.

Amanda Fried of the city’s Office of the Treasurer and Tax Collector said she can’t comment on a particular taxpayer’s obligations. Generally speaking, businesses that process a payment between third parties do not need to include the full amount of a transaction in their gross receipts but may owe tax on a “lesser amount,” she said.

Stripe has donated $19,999 to the Chamber of Commerce’s “No on Prop. C” campaign; its general counsel, Jon Zieger, wrote an opinion piece in The Chronicle urging a no vote on the measure.

Stripe CEO Patrick Collison said in a tweet he supports Dorsey. Dorsey retweeted Collison’s tweet, broadcasting it to his 4.1 million followers.

Benioff noted that Stripe had recently been valued by investors at $20 billion. Collison and his brother, John, reportedly own nearly a quarter of the company, making their stake worth billions.

“The first day we started Salesforce, we committed 1 percent of our equity, time and product,” Benioff said, noting a pledge the company had made to donate shares and software and commit employees’ volunteer time.

Gensler, a San Francisco design and architecture firm, last month donated $10,000 to the “No on Prop. C” effort.

Later on Friday, Benioff tweeted, “If you’re going to fight a relatively small tax, which is one half of one percent to help our number 1 issue, then you better be prepared to talk about what you are doing versus what you don’t want to do.”

San Francisco Chronicle business editor Owen Thomas and staff writer Dominic Fracassa contributed to this report.

Melia Russell is a San Francisco Chronicle staff writer. Email: melia.russell@sfchronicle.com