The Buffalo Bills are putting the finishing touches on a five-year deal that will make Rex Ryan their next head coach, sources told ESPN NFL Insider Adam Schefter.
The hiring of Ryan, who will earn a salary of $5.5 million per year, would complete an extensive coaching search for the Bills, who have interviewed 12 candidates since Doug Marrone opted out of his contract on Dec. 31.
The Bills conducted a second interview with Ryan on Saturday night, sources told ESPN. He also interviewed for the Falcons' coaching vacancy.
But when the Falcons dragged their feet on hiring Ryan, which they strongly considered doing at one point last week, the former Jets coach agreed to Buffalo's wishes for a second interview and the new deal, sources told ESPN.
Ryan and the Bills are expected to hire 49ers offensive coordinator Greg Roman for the same position in Buffalo, sources told ESPN. Ryan and Roman previously worked together as assistant coaches with the Ravens.
The Bills also have said they would like to keep Jim Schwartz as defensive coordinator. Ryan already has spoken to Schwartz about staying with Buffalo, a league source told ESPN. But Schwartz runs a 4-3 defensive scheme with a wide-9 front -- used consistently this year only by the Bills and Lions, according to a source -- while Ryan prefers a hybrid 3-4 scheme.
This is the Bills' sixth coaching search since Wade Phillips was fired after the 2000 season and the first since Terry and Kim Pegula bought the team from the estate of Hall of Fame owner Ralph Wilson in October. The Pegulas were involved in all the interviews, many of them done at their South Florida home.
The Bills went 9-7 this past season to match their best record in a decade, but missed the playoffs to extend the NFL's longest active drought to 15 seasons.
Ryan is very familiar with the Bills after spending the past six seasons coaching their AFC East rival. He had a 50-52 record, including 4-2 in the playoffs, with the Jets before being fired along with general manager John Idzik following a 4-12 finish. Ryan is not expected to bring many, if any, of his former Jets offensive assistant coaches to Buffalo, according to a source.
Ryan's father, Buddy, also had ties to Buffalo after serving as an assistant coach at the University at Buffalo from 1961 to '65.
Ryan's strength is defense, as it is with the Bills. Buffalo's defense finished fourth in the NFL in yards allowed, recorded a league-leading 54 sacks last season and produced three Pro Bowl linemen.
Ryan's challenge in Buffalo would be similar to the one he had in New York: providing a spark to a sputtering offense. The Jets finished 22nd in yardage last season -- four spots ahead of Buffalo.
Quarterbacks were concerns for both teams, involving two players drafted in 2013.
The Jets faltered behind second-year starter Geno Smith, who was eventually benched and replaced by Michael Vick. In Buffalo, second-year starter EJ Manuel was benched after four games and replaced by 10-year journeyman Kyle Orton, who has since said he plans to retire.
Manuel has two years left on his contract and is the only experienced starter on the Bills' roster.
Roman is regarded as a good fit under Ryan, because the two share a similar run-first philosophy. Under Roman, the 49ers' running attack ranked among the NFL's top 10 in each of the past four seasons.
Ryan will become the first coach to change teams within the same division since Bill Parcells joined the Jets in 1997, according to ESPN Stats & Information. Parcells coached the New England Patriots the previous season.
ESPN NFL Insider Adam Caplan and The Associated Press contributed to this report.