The Athletics were trailing 8-6 when Derek Norris singled off Brian Matusz in the bottom of the ninth and Yoenis Cespedes -- who came off the disabled list before the game -- tied the score with a home run.
Sogard led off the bottom of the 10th with a single against Pedro Strop (0-1) and was safe at second when Strop threw wildly to the bag on Adam Rosales' grounder.
Coco Crisp laid down bunt and third baseman Machado fielded it and threw to shortstop J.J. Hardy at third in a bid to throw out Sogard. But the throw sailed past Hardy, allowing Sogard to come home with the game-winner.
Machado went 4-for-5 with two RBI and Nate McLouth added four hits and scored four runs for the Orioles.
Chris Davis drove in three runs for Baltimore.
Couple mistakenly served bag of cash at McDonald's drive-thru
Jordana Brewster on Paul Walker: 'He was an enormous presence in my life'