Edson Buddle had the Galaxy ahead at halftime with his league-leading 11th goal, but United answered through Andy Najar in the 54th minute. However, D.C. defender Julius James was called for a handball inside his own penalty area as he blocked the shot of L.A.'s Sean Franklin, allowing Donovan to fire home the winning goal.
The win helps the Galaxy move nine points clear at the top of the Western Conference table, while D.C. sits on the bottom of the standings in the Eastern Conference and is now winless in its last five games.
Buddle had a close-range effort kept out by United goalkeeper Troy Perkins midway through the opening half, but he made the most of his next opportunity in the 38th minute to give the Galaxy the lead.
After working his way into the penalty area, Buddle's initial effort was blocked by D.C.'s Dejan Jakovic. However, he picked up the loose ball and fired a left-footed shot past the keeper to make it 1-0.
Pablo Hernandez had a good chance for D.C. two minutes later, but his free kick from the right wing was saved at the near post by L.A. goalkeeper Donovan Ricketts.
The Galaxy should have added a second goal shortly after halftime as Donovan's low ball to the back post was just out of the reach of Alan Gordon, while United equalized six minutes later.
Hernandez swung a free kick into the middle of the area for Najar, and he rose up in traffic to get his head on the ball, redirecting it past Ricketts.
However, the Galaxy regained the lead four minutes later when James handled Franklin's shot inside his own area, allowing Donovan to smack the ball just out of the reach of Perkins and inside the right post from the spot.
Jordan Graye went close with a 30-yard effort that skipped past the post for United, while the final opportunity for the hosts arrived in the 89th minute as Hernandez headed the ball over Ricketts from six yards but watched it narrowly sail over the crossbar as well.