The measure, approved on a five to three vote, prohibits stores larger than 8,100 square metres that use 10 per cent of space to sell groceries and other merchandise.
The vote is aimed at Wal-Mart Supercenter shops, which average 16,650 square metres.
Tony Young, a councillor, who supported the ban, said: "I have a vision for San Diego and that vision is about walkable, livable communities, not big, mega-structures that inhibit people's lives."
San Diego is the United States' eighth-largest city.
Kevin McCall, Wal-Mart's spokesperson, said that the Arkansas-based company, may consider a legal challenge or voter referendum if the measure becomes law.
"Certainly we're disappointed, but there's still a number of steps left in this process," he said. "We need to look at what our options are."
Jerry Sanders, San Diego's mayor, will veto the ban if the council reaffirms it on a second vote.
Fred Sainz, the mayor's spokesperson, said the vote was expected in January.
"What the council did tonight was social engineering, not good public policy," Sainz said.
The council can override his veto with five votes.
Big business
Supporters of the ban argued that Wal-Mart puts smaller competitors out of business, pays workers poorly, and contributes to traffic congestion and pollution.
Those against the ban said large shops provide jobs and low prices and that a ban would limit consumer choice.
Kevin Faulconer, a San Diego councillor who opposed the ban, said: "Quite simply, I do not think it is the role of the San Diego City Council to dictate where families should buy their groceries."
Wal-Mart has about 2,000 Supercenter shops, including 21 in California, but none in the San Diego area.
Wal-Mart has not disclosed plans for an outlet in the San Diego area, but many analysts believe that the retailer probably wants to expand.
San Diego's move comes two months after the Chicago City Council failed to override Mayor Richard Daley's veto of a so-called "living-wage" rule that would have required giant retailers to pay their workers higher wages