The Houston Astros have agreed to a three-year, $18.5 million contract with Luke Gregerson and also have agreed to sign reliever Pat Neshek, sources told ESPN's Buster Olney, confirming multiple reports.

Luke Gregerson will remain in the AL West next season, leaving the A's to sign with the Astros. Michael Zagaris/Oakland Athletics/Getty Images

Gregerson is expected to take over as the team's closer in 2015 with Neshek, coming off a career season, helping to fortify the back end of the bullpen.

Gregerson's total compensation from the Astros can increase to $21 million if he is the team's closer, a baseball source told ESPN.com's Jerry Crasnick.

His agreement comes after the Astros reportedly made attempts to sign both David Robertson and Andrew Miller this offseason to take over their closer's role. Robertson ended up agreeing to a four-year deal with the Chicago White Sox, while Miller reached a four-year contract with the New York Yankees.

Neshek is guaranteed $12.5 million over two years, a baseball source told Crasnick. He'll make $5.5 million in 2015 and $6.5 million in 2016. The deal has a $500,000 buyout, and includes a third year club option for between $6.5 million and $9 million. The amount of the option will increase depending on the number of games Neshek finishes in his first two seasons.

Veteran Chad Qualls was the Astros' closer in 2014, saving 19 games and finishing the season with a 1-5 record and a 3.33 ERA. Qualls, who is under contract with the Astros for the 2015 season, likely will move to a setup role.

Gregerson, a 30-year-old right-hander, was 5-5 with three saves and a 2.12 ERA last season for the Oakland Athletics, who acquired him from the San Diego Padres in exchange for outfielder Seth Smith after the 2013 season.

In six seasons with the Padres and A's, he is 22-27 with a 2.75 ERA.

Neshek was a first-time All-Star last season, his first with the St. Louis Cardinals. He finished 7-2 with six saves and a 1.87 ERA as a setup man for the National League Central champions.

In eight seasons with the Minnesota Twins, Padres, Athletics and Cardinals, the 34-year-old right-hander is 23-11 with six saves and a 2.78 ERA.

Gregerson was paid $5,065,000 last season, while Neshek made $1 million in 2014.