The Dolphins committed an error off the snap on offense for the second time in as many matches as the ball flew over the head of Ryan Tannehill and out of the endzone, handing the Bills a two-point safety.
Rex Ryan's men extended their advantage when Tyrod Taylor handed off to McCoy and the back found a hole in the Dolphins' defense to race through and find the endzone for a 48-yard score.
Miami got back into the match when Tannehill completed a series of throws to drive his team to the goalline, and Lamar Miller completed the score when he drove in from one yard.
Dan Carpenter made a 43-yard field goal to hand his side a five-point lead before Williams found the endzone to ensure that his side would lead at the break with a 29-yard run.
The Dolphins had the chance to notch a touchdown before the break, but with two seconds left in the half they opted for a shot at the endzone rather than a field goal. Tannehill's attempted pass to Jarvis Landry was broken up Stephon Gilmore, leaving his side to trail by 12.