The shootout occurred in the early hours of Monday after an attack against a naval infantry force patrol in the Villas de Cortes district of the town, the state's security coordination group, made up of federal and local forces, said.
The attack was met with response fire, killing seven gang members, including five men and two women. A soldier was wounded in the ensuing firefight and later died in hospital. An investigation into the attack and the identity of the attackers is underway.
San Jose del Cabo, as well as its neighboring Cabo San Lucas, are among Mexico's major tourist destinations. The twin resorts, located on the southern tip of the Baja California peninsula, have seen escalating drug cartel violence over the past year, with rival gang clashes leaving scores of people dead on a regular basis.