The Red Wings had to struggle for the win after blowing a four-goal lead.
Edmonton rallied from a 4-0 deficit to produce a 4-4 tie with 9:30 remaining in the game, but Stuart's goal on Datsyuk's shot from the top of the left circle rescued Detroit's evening.
Johan Franzen notched with a goal and an assist and Jimmy Howard made only 22 stops as the Red Wings won their sixth straight. Detroit stood one point behind Nashville for fifth place in the West as the Predators prepared to play seventh-seeded Los Angeles late Tuesday.
Tom Gilbert notched a pair of goals for the Oilers while Mike Comrie chipped in with a goal and an assist in the loss, which assured Edmonton of the worst record in the NHL this season.