Francisco Salazar, a close ally of the Spanish prime minister, stepped down from his position in the Socialist Party amid allegations of sexual harassment.