The Yankees are taking a shot on a former All-Star.

The club agreed on Tuesday to a minor-league deal with reliever Trevor Rosenthal, The Post’s Joel Sherman confirmed.

Rosenthal, 29, elected for free agency earlier this month after being designated for assignment by the Detroit Tigers.

The Washington Nationals signed Rosenthal, a 2015 All-Star as the closer for the St. Louis Cardinals, to a one-year, $6 million deal with a $1 million buyout on a 2020 option after he missed 2018 because of Tommy John surgery.

Once a feared flamethrower, Rosenthal had a whopping 22.74 ERA in 12 appearances with the Nats before he was released in June. He caught on with the Tigers and had a 7.00 ERA in 10 appearances.