Dmitry Sychev and Malkhaz Asatiani scored the all-important goals in the 75th and 85th minutes after Vadim Yevseyev had missed a penalty in the opening minutes.
Lokomotiv also survived a penalty after Asatiana brought down Cameroon midfielder Armand Dubois Jankep in the box. But Pance Stojanov failed to convert and within five minutes Sychev finally managed to capitalize on one of the home side's many chances.
Asatiana sealed victory after picking up a pass from Dmitry Khokhlov.
The sides drew the first leg in Macedonia 1-1, which left Lokomotiv advancing with an aggregate 3:1 victory.