An implantable medical device (100) applies an electric signal over two electrodes (216, 218) and measures the resulting electric signal over a candidate pair of neighboring electrodes (212, 214) on a lead (210) for a first heart ventricle (12) or over a candidate electrode (218) of the lead (210) and a case electrode (102). An impedance signal is determined for each candidate pair (212, 214) or electrode (218) based on the applied signal and the measured resulting signal. A time difference between start of contraction in a second ventricle (14) as caused by application of a pacing pulse to the second ventricle (14) and the timing of local myocardial contraction as identified from the impedance signal at the site of the candidate pair (212, 214) or electrode (218) is determined for each candidate pair (212, 214) or electrode (218). An optimal pacing electrode is selected to correspond to one of the electrodes of the candidate pair having the largest time difference or the candidate electrode having largest time difference.