Trailing 5-4 entering sixth, the Athletics struck for five runs that decided the contest.
Coco Crisp's one-out double drove in Chris Pennington with the score-tying run off Latroy Hawkins (2-3) and went to second one out later when Josh Reddick drew a walk.
Both advanced on a double-steal and Cespedes followed by slicing a pitch into right field, sending them home for a 7-5 Oakland lead.
Carter then capped the rally with a two-run shot to left as the A's won the three-game series.
Pat Neshek (1-0) earned the victory for Oakland, which came into the game in a three-way tie with Detroit and Baltimore for the American League wild card lead.
The Angels, who entered the contest a half-game behind the trio, got a two-run single from Howie Kendrick in the ninth but Ryan Cook hung on for his 12th save.
Kendrys Morales went 3-for-5 with two homers and three RBI, while Mark Trumbo and Hunter also went deep for Los Angeles.