ATLANTA -- It took a miracle for the Atlanta Falcons to remain undefeated last week against the Detroit Lions. The Falcons couldn't get another miracle on Sunday against the Buffalo Bills.

The Bills handed the Falcons their first loss of the season, beating them 23-17 at Mercedes-Benz Stadium on Sunday.

Quarterback Matt Ryan looked off throughout most of the game, but he struggled mightily when both his leading receivers left the game with injuries. Julio Jones left in the first half with a hip injury. Mohamed Sanu left with a hamstring injury.

Ryan completed 24 passes on 42 attempts for 242 yards. His only touchdown pass was to Justin Hardy that tied the game at 17 midway through the fourth quarter.

The Falcons offense struggled to gain much yardage in the first few series. Tevin Coleman broke free for 29 yards, setting up a field goal by Matt Bryant.

But the Bills responded right away. Tyrod Taylor connected with Charles Clay for 44 yards and then with Jordan Matthews from 9 yards out to get their first lead.

Just before halftime, Coleman made a 39-yard reception on the sideline, and Sanu ran to the goal line out of the wildcat to set up a 1-yard touchdown run by Devonta Freeman.

Coleman rushed for 58 yards on nine attempts. Freeman had 79 yards on 18 attempts.

But the Bills defense-- one of the top defenses in the NFL-- capitalized off mistakes by the Falcons offense. After the Falcons' top two receivers left the game with injuries, Ryan was searching for other receivers. He threw a jump ball to Taylor Gabriel that was intercepted by Micah Hyde. Prior to that, Ryan fumbled while getting hit by Jerry Hughes and Tre'Davious White returned it 52 yards for a touchdown.

Ryan's first interception led to a long, 11-minute drive by the Bills that led to a field goal by Stephen Hauschka. Hauschka was 3-for-3 and kicked field goals from 56 and 55 yards out to build a six-point lead.

Ryan threw another interception on a pass Nick Williams tipped and Hyde intercepted, running 37 yards before getting tackled. The pick led to Hauschka's third field goal.

That field goal proved to be key. Ryan and the Falcons moved into the red zone with under a minute to go, but Ryan's throw to Taylor Gabriel of fourth down was incomplete.

The Falcons went into the game with several key injuries, including safety Ricardo Allen, right tackle Ryan Schraeder and defensive lineman Courtney Upshaw.

PHOTOS | Falcons vs. Bills