A person familiar with the negotiations said McKelvin agreed to a four-year contract worth a little over $20 million. The person spoke on condition of anonymity because the Bills have not announced the move, which was first reported by foxsports.com earlier in the day.
The deal was reached before McKelvin was eligible to become an unrestricted free agent on Tuesday.
McKelvin had expressed interest in returning to Buffalo, though he was free to begin entertaining offers from other teams starting Saturday. That's when a three-day window opened allowing teams to contact prospective free agents to gauge their interest before the signing period began.
Selected 11th overall out of Troy, McKelvin has had difficulty maintaining a starting job in his five seasons in Buffalo.
Used mostly as a third cornerback last year, McKelvin had one interception in 13 games, including four starts. He missed the final three games because of a groin injury. Overall, he has six interceptions in 64 games, with only 33 starts.
McKelvin has made a bigger impact on special teams, having combined for four touchdowns returning kickoff and punts. Last year, he led the NFL averaging 18.7 punt return yards, and became the first Bills player to return two punts for touchdowns in one season. As a rookie, McKelvin set the single-season franchise record with 1,468 yards on kickoff returns.
The Bills were preparing to enter free agency lacking experienced depth at cornerback, especially after cutting veteran Terrence McGee last month. McKelvin will be given the opportunity to compete for a starting job opposite Stephon Gilmore, the team's first-round pick last year. Returning starter Aaron Williams struggled at the position last season.
McKelvin will be part of a defense that's going through a transition under new coach Doug Marrone, who takes over after Chan Gailey was fired in January following three losing seasons. Marrone has brought in an entirely new coaching staff, which includes former New York Jets defensive coordinator Mike Pettine in the same role in Buffalo.
General manager Buddy Nix had expressed interest in re-signing McKelvin. At the NFL combine last month, Nix listed McKelvin along with safety Jairus Byrd and guard Andy Levitre as the top three pending free agents he would like to keep.
The Bills placed the franchise tag on Byrd to retain his rights last week.
Levitre, a four-year starter, remains unsigned and is expected to test free agency.