With 10:59 left in the first half, the Dolphins got on the board with a 7-yard pass from Tannehill to tight end Charles Clay.
The Dolphins got the ball right back at the Buffalo 31 after safety Chris Clemons intercepted Lewis on a pass over the middle intended for Stevie Johnson.
But Miami could not move the ball, and Caleb Sturgis' 51-yard field goal attempt was wide right.
Buffalo extended its lead to 17-7 with a 39-yard field goal by Carpenter.
The Dolphins closed the first-half scoring with a 13-yard touchdown pass to Gibson with 21 seconds left. Gibson took a hit and vaulted about 5 yards to complete the play, capping a 75-yard drive that took just 1:04 and closed Miami's deficit to 17-14.
Notes: Johnson returned to the starting lineup after missing one game due to a back injury. ... Robey is a native Floridian (Frostproof). ... Bills LB Manny Lawson left the game in the third quarter due to a hamstring injury. ... Dolphins DE Cameron Wake, who missed all but three plays of the past two games due to a knee injury, returned to the starting lineup. ... The Dolphins started Jason Trusnick at MLB in place of leading tackler Dannell Ellerbe (shoulder injury). It was just the eighth start in the past four years for Trusnick, 29.