SAN FRANCISCO (AP) The Washington Nationals have acquired All-Star closer Mark Melancon from the Pittsburgh Pirates.

Washington sent reliever Felipe Rivero and pitching prospect Taylor Hearn to the Pirates for Melancon, who supplants Jonathan Papelbon as Washington's closer.

Melancon, a 31-year-old right-hander, has 30 saves and a 1.51 ERA this season. He is making $9.65 million and is eligible for free agency after the World Series.

More from FoxSports

Papelbon is 2-4 with a 4.41 ERA and has allowed eight runs and seven hits in his past three outing. Manager Dusty Baker wouldn't say earlier Saturday whether Papelbon still was his closer. Baker pulled Papelbon from a game Thursday in the ninth inning.

Rivero, a 25-year-old lefty, is 0-3 with a 4.53 ERA this season. Hearn is a 21-year-old lefty who was the Nationals' fifth-round pick in the 2015 amateur draft.