Mayberry finished 2-for-3 with two RBI as the Phillies snapped their season-long skid in the first contest of a nine-game homestand.
Lannan (3-4) gave up three runs on seven hits over seven innings to collect the win, issuing two walks while striking out three.
Giants starter Barry Zito (4-8) was touched for four runs on five hits in a 3 1/3-inning stint.
Pablo Sandoval drove in a pair of runs for San Francisco, which tumbled to a fifth straight loss.
Selena Gomez drops F-bomb, walks off stage during Jingle Ball performance
Reindeer recovered after escaping from Santa during lighting ceremony