PP candidate Bartolomé Guerra will keep his job as mayor of the village of Tolox in the Sierra de las Nieves, after winning a tie-breaker draw held in Malaga city's court complex on Friday morning.
Control over the local council was left to the luck of the draw after both the PP and PSOE parties obtained 603 votes each in the municipal elections.
On Friday the central electoral commission upheld a decision to declare a damaged voting paper in favour of the Socialist PSOE party null and void.
The paper, which would have given the PSOE electoral victory, had been cut in several places.
While previous reports had suggested that the winner would be decided by tossing a coin, in the end one of the journalists covering the event was asked, with the agreement of both parties, to choose one of two sealed envelopes placed on a table.
At the end of the draw the representatives of both parties shook hands. The candidates, Bartolomé Guerra (PP) and Francisca García (PSOE) had agreed not to attend the draw in person.