Josh Saunders also earned his ninth shutout for the defending league champion Galaxy, who got a late goal from a veteran substitute to win a game with much more importance for Seattle.
Los Angeles already was locked into fourth place in the Western Conference. The Galaxy will host the Vancouver Whitecaps on Thursday night in a one-game knockout playoff for the right to face top-seeded San Jose in the conference semifinals.
The loss left Seattle in third place in the West with 56 points, allowing Real Salt Lake to finish second with 57 points.
A win or tie would have put the Sounders into the second slot, but Salt Lake will have home-field advantage in the second game of their conference semifinal.
After a lively game featuring numerous near-misses by both offenses, Magee scored from just outside the penalty area when the Sounders left him unmarked. Magee easily converted a pass from Keane, who capped his standout second half of the season with several near-goals and the decisive assist.
Magee's goal was just the 15th allowed in 21 games by Michael Gspurning, the Sounders' Austrian goalie. Seattle allowed just 33 goals this season, fewest in the West.
Sounders forward Eddie Johnson also left late in the first half with an apparent hamstring injury. Johnson leads Seattle with 14 goals.
Brad Evans appeared to score a tying goal in the final seconds of injury time, but teammate Fredy Montero was called for a handball an instant earlier.
Landon Donovan and David Beckham also returned to the starting lineup after injury absences for the Galaxy, who snapped their three-match winless skid. Los Angeles also avoided a three-game season series sweep by the Sounders, who haven't beaten the Galaxy at Home Depot Center since 2009.
Beckham played 62 minutes against the Sounders, and Donovan played the entire game. Donovan missed the Galaxy's last game with a bone bruise on his left knee, and Beckham also sat out to rest his sore left ankle.
Beckham and Keane missed scoring strikes by a few inches in the first half, both curling shots just outside the post. Keane nearly scored on a leaping volley off a sharp cross from Donovan in the 41st minute.
Keane barely missed the net again in the 46th, chipping a shot just wide over Gspurning. He put another beautiful shot just off the crossbar in the 53rd minute, freezing Gspurning as he watched the high-arcing ball go over his head.
Lakers forward Pau Gasol and comedian Russell Brand attended the game.