NASHVILLE — Free-agent reliever Joakim Soria, who pitched for the Pirates for two months in 2015 after they acquired him at the trade deadline, agreed to terms Sunday night on a three-year, $25 million contract with the Kansas City Royals, according to a source.

The contract includes a mutual option for 2019. ESPN first reported the agreement.

Soria, a 31-year-old right-hander, had a 2.03 ERA and struck out 28 batters in 262/3 innings with the Pirates. They sent minor league shortstop JaCoby Jones to the Detroit Tigers in exchange for Soria; Jones received a 50-game suspension in November for violating Major League Baseball’s joint drug prevention and treatment program by testing positive for a drug of abuse.

Soria broke into the majors with the Royals in 2007 and pitched there for five seasons, making two All-Star teams. The Royals won the World Series this past season. They lost closer Greg Holland for 2016 because of Tommy John ligament replacement surgery.

Bill Brink: bbrink@post-gazette.com and Twitter @BrinkPG.