SAN DIEGO — The election of a Republican city councilman to become San Diego’s mayor became a rare bright spot for a party that has been eclipsed at the state level in California.

The victory by the councilman, Kevin Faulconer, on Tuesday will make San Diego the largest city in the nation run by a Republican, and it raises the possibility that he could become an important leader in the efforts to strengthen the party in California. Mr. Faulconer, 47, a former public relations executive, won with 55 percent of the vote, compared with 45 percent for his Democratic opponent, David Alvarez.

The special election came nearly six months after Bob Filner, the city’s first Democratic mayor in decades, resigned amid allegations that he had sexually harassed dozens of women, including many local leaders.

“Together, we sent a very strong message tonight: that this city needs to have an independent leader, and that the city will stand up and work together,” Mr. Faulconer told supporters in downtown San Diego. “Every San Diegan has a chance at success and has a seat at the table.”