Boston Red Sox pitcher Matt Barnes (32) delivers against the Oakland Athletics in Oakland, Calif., on July 4.
Boston Red Sox pitcher Matt Barnes (32) delivers against the Oakland Athletics in Oakland, Calif., on July 4. Credit: AP — D. Ross Cameron

BOSTON — The Red Sox signed reliever Matt Barnes to a two-year deal that runs through the 2023 season, the club said Sunday.

The 31-year-old Barnes is 4-2 with a 2.68 ERA and has 19 saves for the Red Sox in 23 opportunities this season. He was one of five Boston players selected for the All-Star Game. It will be his first All-Star appearance.

Barnes has spent his entire career with Boston, which selected him No. 19 overall in the 2011 draft from UConn.