SAN FRANCISCO -- Jake Lamb hit a tying homer with two outs in the ninth inning and doubled home an insurance run in the 11th, rallying the Arizona Diamondbacks past the San Francisco Giants 9-7 on Monday night.

Phil Gosselin scored on Jean Segura's go-ahead infield single with two outs in the 11th. Lamb, who homered to right field off closer Santiago Casilla two innings earlier, made it a two-run cushion with his RBI double.

Segura and Lamb had three hits apiece. Welington Castillo homered and drove in two runs for Arizona.

More from FoxSports

Rubby De La Rosa (1-3), scratched from his scheduled start in this series opener after coming out of the bullpen over the weekend, struck out three for the win.

Brad Ziegler pitched the 11th for his third save this season and 31st consecutive overall -- an ongoing franchise record.