The deal, which buys out two years of free agency, is worth $17.5 million, a source told ESPN's Jeff Passan. It also includes a vesting option for the 2022 season.
Pressly would have been eligible for free agency after this season.
"I wasn't really paying attention to that stuff," he said. "This is just a good fit for me and my family, being from Texas and my fiancé from Houston and a lot of my friends and family are in Houston. This was a big reason I wanted to be a part of the Astros."
The Astros acquired Pressly from the Minnesota Twins in July for two prospects: right-hander Jorge Alcala and outfielder Gilberto Celestino.
The Houston Chronicle first reported terms of the deal.
The 30-year-old Pressly was a combined 2-1 with a 2.54 ERA and 101 strikeouts in 77 appearances last season. He added depth in the bullpen for an Astros team that sent closer Ken Giles to the minors before the All-Star break after he struggled earlier in the season.
Pressly, who had spent his entire six-year career with the Twins before the trade, has a career record of 18-16 with three saves and a 3.54 ERA in 307 games.
"Having stability in our bullpen was an objective that we were trying to accomplish here and Ryan in our opinion has been one of the top 10 relievers in baseball for the past few years," president of baseball operations Jeff Luhnow said. "To be able to lock him up and know that he's going to be with the Houston Astros for the next three-plus years was an important consideration for us."
The Associated Press contributed to this report.