The present invention relates to a process for the preparation of pimozide, characterized in that the reaction for obtaining said active ingredient is carried out in glycerol formal as an inert solvent at a pH higher than 4 and wherein said reaction is a S N 2 nucleophilic substitution.