Ryan, who signed a five-year deal, will be introduced at a news conference Wednesday.
The hiring of Ryan, who will earn a salary of $5.5 million per year, completes an extensive coaching search for the Bills, who interviewed 12 candidates since Doug Marrone opted out of his contract on Dec. 31.
"Following an extensive search, we are pleased today to announce that Rex Ryan is our new head coach," Bills owner Terry Pegula said in a statement. "Rex brings a wealth of experience and enthusiasm to the position that we feel will be a tremendous benefit to our players and the entire Bills organization."
The Bills conducted a second interview with Ryan on Saturday night, sources told ESPN. He also interviewed for the Falcons' coaching vacancy.
"He was very impressive during the interview process, as were many of the candidates to which we spoke, and we feel Rex is the best fit for our team," Pegula said. "We look forward to his leadership and expertise in directing our team to the playoffs and bringing a championship to Buffalo for our fans."
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. 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.
Bills players reacted favorable to Ryan's "ground and pound" style of play, especially running back Fred Jackson, a team captain.
"Those are a running back's favorite words," Jackson told The Buffalo News. "He wants to beat people running the ball."
Bills defensive coordinator Jim Schwartz will not return for the 2015 season, a league source told ESPN's Adam Caplan on Monday night. The reason, according to the source, was due to differing defensive philosophies with Ryan.
Dennis Thurman, who was Ryan's defensive coordinator with the Jets the last two seasons, is expected to take over as defensive coordinator with the Bills.
Schwartz ran a 4-3 defensive scheme with a wide-9 front -- used consistently this season only by the Bills and Lions, according to a source -- while Ryan prefers a hybrid 3-4 scheme.
This was 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 season to match their best record in a decade, but they missed the playoffs to extend the NFL's longest active drought to 15 seasons.
Ryan is familiar with the Bills after spending the past six seasons coaching an 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.
"I'm excited about him coming here," Jackson told The Buffalo News. "He's larger than life, and he's going to do everything to protect his name, and the best thing he can do is win football games.
"We made some improvements last year, and I'm sure that was appealing to him. He wants to get us out of this playoff drought. He knows what he's signing up for. That means he wants to be here and keep this thing going in the right direction."
Excited about the hire of Rex!! Great coach to come in and keep us moving in the right direction!
— Fred Jackson (@Fred22Jackson) January 11, 2015
The new head coach's strength is defense, as it is with the Bills. Buffalo's defense finished fourth in the NFL in yards allowed this season, recorded a league-leading 54 sacks and produced three Pro Bowl linemen.
Ryan's challenge in Buffalo is similar to the one he had in New York: providing a spark to a sputtering offense. The Jets finished 22nd in yardage this season -- four spots ahead of Buffalo. Quarterbacks were concerns for both teams, involving two players drafted in 2013 (the Jets' Geno Smith and Bills' EJ Manuel).
Manuel has two years left on his contract and is the only experienced starter on the Bills' roster.
ESPN NFL Insider Adam Caplan and The Associated Press contributed to this report.