The 49ers were clinging to a 19-17 lead with 3:56 remaining in the game after the Seahawks' Tarvaris Jackson found Doug Baldwin on a 55-yard touchdown pass.
But Ginn returned the ensuing kickoff 102 yards for a score, then took a punt 55 yards into the end zone only a minute later to wrap up the win.
David Akers booted four field goals and Alex Smith completed 15-of-20 passes for 124 yards as the 49ers won in Jim Harbaugh's debut as an NFL head coach.
Jackson turned the ball over three times with a pair of fumbles and an interception in his first start for the defending NFC West champion Seahawks.
Celebrity Breakups and divorces of 2014 [PHOTOS]