Center Marcel Dionne scored two goals 23 seconds apart in the first period and also had two assists, including one on Brian MacLellan's game-winning power-play goal one minute into the third period.
Although he did not score a goal, Gretzky, the leading scorer in the National Hockey League, did get a second-period assist on a goal by Mike Krushelynski to extend his scoring streak to 19 consecutive games. Gretzky needs just five assists to break his NHL record of 125 set in the 1982-83 season.
King Coach Pat Quinn had Dionne shadow Gretzky wherever he went.
"We haven't had a whole lot of success against him so I wanted to try something different," Quinn said.
The slumping Oilers are 2-5-3 in their last 10 games.
"We have been trying hard to get out of this," Gretzky said. "Maybe we're a little too tense."
Said Edmonton Coach Glen Sather: "We've been having our problems the last couple of weeks. I think that we're just starting to get our game back on track now, but we're not moving the puck the way we can. We're not scoring when the opportunities present themselves."
The Kings and Oilers are likely to meet again in the first round of the playoffs next month.
"I think the Kings are one of the best teams in the NHL today," Sather said. "You look at all four teams in our division and they are all right up there in the top 10. The Kings are a good hockey team right now and they're going to give anyone they play problems."
With the Kings leading, 4-3, at the start of the third period, MacLellan scored what turned out to be the game-winning goal on a power play.
The Oilers cut the margin back to one just 46 seconds later, however, when center Mark Messier scored to make it 5-4.
Edmonton had a chance to tie after getting a power play with 13:10 left when King left wing Dave (Tiger) Williams was penalized two minutes for hooking.
But the Oilers came away empty, hitting the post on three-consecutive shots, two by Messier and one by Gretzky.
The crowd was on its feet for the last minute of the game. Edmonton called a timeout with 54 seconds left and pulled goalie Grant Fuhr for an extra skater.
The Oilers rushed the net with 29 seconds left and King goalie Bob Janecyk was shaken up when Oiler left wing Dave Semenko elbowed him in a pileup in front of the net.
But Janecyk was able to continue, making a diving save on a shot by Jarri Kurri with 24 seconds left.
"The last 24 seconds was like having a free throw late in a basketball game and having your guy miss the hoop," Sather said.
The victory left the Kings (32-26-13) three points behind the third-place Calgary Flames in the Smythe Division. The Oilers (45-17-9) already have wrapped up first place in the division.
Dionne scored his first goal just 2:18 into the game off a pass from MacLellan, then scored another 23 seconds later off a two-on-one break.
The Oilers, however, scored two of their own to end the first period tied, 2-2.
Paul Coffey got his 27th goal of the season on a power play at 11:27 and right wing Dave Lumley tied it with his ninth goal at 12:42.
King right wing Steve Shutt tipped in a shot by defenseman Jay Wells 1:16 into the second period to give the Kings a 3-2 lead, but the Oilers tied it at 3-3 when Krushelynski scored a power-play goal off a pass from Kurri.
With just 23 seconds left in the second period, King defenseman Mark Hardy scored a power-pay goal on a shot that hit the post and trickled over the line.
The Kings open a two-game trip Tuesday against the New York Islanders. They play in Detroit Wednesday before returning home to meet the Calgary Flames Saturday at the Forum. . . . The Kings play the Oilers just once more during the regular season, on April 2 at the Forum. Sunday night's sellout was the eighth of the season.