Landon Donovan had a goal and an assist for the Galaxy (8-10-2), who handled the Timbers defense.
Portland (5-9-4) struggled in its first game since coach John Spencer was fired and Gavin Wilkinson took over the team.
Kris Boyd scored two goals for the Timbers, who lost for only the third time in 10 games at Jeld-Wen Field this season.
Wilkinson understood the firing of Spencer was likely going to have an effect on the team's play for a while.
After the game he told the players, ''this one's on me.''
''It's been a really crazy last week,'' said Kosuke Kimura, who joined the Timbers July 5 from Colorado. ''Everything happened so quick. But at the same time it's a professional business.''
The Timbers took a 1-0 lead in the third minute when Boyd scored off a cross from Kalif Alhassan.
The Galaxy got their offense going in the 20th minute, when Beckham sent the ball into the back of the net.
Beckham gave the Galaxy a 2-1 lead when he sent a free kick past Portland keeper Troy Perkins in the 24th minute.
Donovan scored his seventh goal of the season on a penalty kick in the 26th minute and then passed to Keane for an easy goal in the 28th.
''That's what happens when you give players of that ability that much time on the ball,'' Boyd said.
Kimura cut the deficit to 4-2 when Galaxy keeper Josh Saunders bobbled a shot in the 35th minute.
Keane scored again in the 64th minute to make it 5-2. Boyd added a goal in the 70th minute for Portland.
The Galaxy are back in the playoff hunt and are in fifth place in the Western Conference. L.A. finishes its three-game road swing at Vancouver on Wednesday.
- Portland Timbers
- Los Angeles Galaxy
- David Beckham
- Robbie Keane
- Landon Donovan