Keith made it four wins from seven league games this season with victory over Lossiemouth but the hosts almost grabbed a point after being three goals down with 10 minutes remaining.
The visitors were ahead after 10 minutes when James Brownie headed home from eight yards following a Michael Selfridge corner and the Maroons doubled their advantage four minutes from the break as Grant Thomson capitalised on poor defending to score with an angled 10-yard drive.
A disputed penalty saw Keith make it three after 56 minutes when Liam Archibald was adjudged to have handled a Thomson shot with the Lossiemouth defender adamant the ball struck his face but Selfridge stroked home the spot kick.
Lossiemouth got a lifeline 11 minutes from time as Ryan Stuart was brought down in the penalty area by Ryan Robertson and Kris Duncan sent Greg Simpson the wrong way from 12 yards.
Duncan netted his second penalty three minutes from time when Adam Clark was sent off for a denying Ross Elliot a goalscoring opportunity and Duncan made an immaculate job of another penalty but it was too little too late for the home side.
Keith manager Dean Donaldson said: “I will be looking at the sending-off as we feel that Adam played the ball. We will possibly appeal the decision as it was a genuine attempt to play the ball.”
Lossiemouth manager Joe Russell felt his team were poor in the first half and not much better in the second half but admitted they deserved nothing from the game, despite their two late goals.
He said: “The penalty given against us was harsh as the ball hit Liam Archibald in the face and to be fair the referee has said that if has made a mistake he will hold his hands up and apologise.”