The defending champion needed three sets to overcome his opponent, but eventually came through 6-1 2-6 6-3 to keep his dreams of a second gold medal alive.
Things looked to be straightforward for the Scot when he raced into a 5-0 lead in the opener, before Fognini was forced to save three set points while finally getting himself on the board.
That proved to be merely delaying the inevitable as Murray served out the set in the very next game, and the world number two also took control of the second with an early break to move 2-1 in front.
However, it would be the last game that Murray won for some time as Fognini reeled off five in a row to take the second set 6-2, and he picked up where he left off in the decider by gaining a 3-0 lead.
Murray finally ended his eight-game losing streak to get on the board at 3-1, and that game was the turning point as he hit back with six games of his own in a row to clinch a hard-fought victory.