The United States international scored his first goal for the German club from Yevhen Konoplyanka's corner late on to settle an otherwise forgettable contest.
Schalke, runners-up in the Bundesliga last term, have endured a stuttering start to the season but picked up their first league points by beating Mainz on Saturday and they now have four in the Champions League having drawn 1-1 with Porto last time out.
Lokomotiv, who did not threaten at all in the second period, have lost both of their Group D games.
Neither side was able to take control during a dull opening 45 minutes.
Dmitri Barinov came closest for Lokomotiv with a half volley that Ralf Fahrmann pushed out, though the Schalke keeper was fortunate he was not punished by a weak punch when Benedikt Howedes' attempted overhead kick went way over before the interval.
Schalke introduced Suat Serdar at half time to try and inject some life into their attack and they were nearly given a helping hand when Vladislav Ignatjev's sliced clearance almost landed at Mark Uth's feet.
There was some improvement from the German side, with Konoplyanka shooting weakly at Guilherme.
Guilherme was far less convincing when he failed to pluck the ball out of the air and was fortunate Uth was not alive enough to flick past him.
Uth ran into the box moments later but fired straight at the Lokomotiv stopper and then curled an attempt just wide as Schalke looked like failing to score for a third time in four matches.
Yet it was McKennie who ensured they found a way through when he rose and planted a header beyond Guilherme with two minutes remaining.
What does it mean: Schalke can look up after successive wins
This was not a performance that suggested Schalke are over their early-season struggles, but manager Domenico Tedesco will feel a whole lot better after back-to-back 1-0 wins.
McKennie delivers late on
He may be just 20 years old, but McKennie was the man to step up when his team most needed him. It is hard to believe it was his first goal with the way he timed his leap and powered his header home.
Lacklustre Lokomotiv offer little
More should have been expected from the Russian club given they were at home. In the second half in particular, they scarcely threatened their opponents' goal.
Key Opta Facts
years, days - Weston McKennie (20 years, 37 days) is the second-youngest American to score in the #UCL since 2003, behind only @cpulisic_10 (18 years, 171 days). Arrival. #LMFCS04 #SchalkeUS pic.twitter.com/x1BUQZeQ0U— OptaJack (@OptaJack) October 3, 2018
- Schalke have only lost one of their last 15 group stage games in European competition (W11 D3).
- Lokomotiv Moscow have lost four consecutive matches in major European competitions (excluding qualifiers) for the first time since September 2003 (five straight defeats).
- The Russian side have now failed to score in nine of their last 12 Champions League group stage games, including both this season so far.
- 60 per cent of the goals scored by American players in the Champions League (excluding own goals) have been scored for German clubs (9/15), including McKennie's for Schalke.
Lokomotiv have a Moscow derby to look forward to this weekend when they face CSKA while Schalke will look to build on their first Bundesliga victory when they travel to Fortuna Dusseldorf.