In this Sept. 4, 2017, file photo, Arizona Diamondbacks' J.D. Martinez gestures toward the camera as he stands in the dugout after hitting his fourth home run of the game in the ninth inning of a baseball game against the Los Angeles Dodgers, in Los Angeles. Credit: Mark J. Terrill | AP

J.D. Martinez and the Boston Red Sox have, at long last, come to an agreement.

The slow dance between the free agent slugger and the power-deficient team wrapped up Monday when they settled on a $110 million, five-year contract.

A person familiar with the negotiations told The Associated Press about the deal, speaking on condition of anonymity because it was subject to a successful physical and had not been announced. Martinez has the right to opt out of the contract early and become a free agent again.

Speculation Martinez and the AL East champions would eventually wind up together had been swirling ever since he became a free agent last November.

Boston was seeking to add power to a lineup that hit an AL-low 168 home runs. The 30-year-old Martinez has changed his swing to improve his launch angle and become one of the top home-run threats in the majors.

The move helps the Red Sox counter the huge deal their biggest rivals pulled off in December. The New York Yankees, who finished two games behind Boston in the division last year, acquired NL MVP Giancarlo Stanton — who led the majors with 59 home runs — in a trade with Miami.

Martinez hit .303 with 45 homers and 104 RBIs last year for Detroit and Arizona, which acquired him on July 18 for three prospects. He had 29 homers and 65 RBIs in 62 games with the Diamondbacks, and hit a record-tying four home runs in a game.

Martinez started a combined 112 games in right field last year. He figures to become the primary designated hitter for the AL East champion Red Sox, which would turn Hanley Ramirez into a platoon player at first with Mitch Moreland.

The righty-swinging Martinez, who began his big league career with Houston in 2011, has played only seven career games at Fenway Park, batting .444 (12 for 27) without an RBI. He figures to knock in plenty of runs when he takes aim at the Green Monster in left.

Martinez was among several prominent free agents still available over the weekend. Eric Hosmer is in the process of finalizing a $144 million, eight-year deal with San Diego while third baseman Mike Moustakas and pitchers Jake Arrieta and Alex Cobb are among the stars looking for places to play.

Hours after Red Sox owner John Henry said talk of collusion in free-agent negotiations was “ridiculous,” his team made a splash by reaching the agreement with Martinez.

“There are a lot of factors, I think, driving it, and I think they’ve all been identified,” Henry said Monday as Boston began full-squad workouts. “There’s a lot of factors that have driven this offseason, and you just can’t expect every season to be a feeding frenzy, so to speak.”

Over the weekend, the Red Sox re-signed infielder Eduardo Nunez to a one-year contract with a player option for 2019, giving them another proven second baseman to fill in while Dustin Pedroia recovers from knee surgery .

Nunez’s deal was done on Sunday, the day before the Red Sox hold their first full-squad workout of spring training. He gets a guaranteed $6 million, according to multiple reports, including $4 million this season and a $2 million buyout. Nunez can reportedly exercise a $4 million option for 2019.

The 30-year-old batted a career-high .313 with 33 doubles and 12 home runs over 114 games last season between San Francisco and Boston. After being acquired by the Red Sox in a trade on July 25, Nunez made 25 of 38 starts at second base. He also hit eight homers in only 38 games for Boston.

“The time I was here last year was amazing,” Nunez told reporters at the team’s facility in Fort Myers, Florida. “There was a lot of energy, and I love to win. I think that’s the best thing, my first choice by far.”

Nunez was limited by a knee injury himself down the stretch last season, appearing in only two games after Sept. 9. One of those was in the AL Division Series.

A native of the Dominican Republic who was signed by the New York Yankees in 2004, Nunez was traded to the Minnesota Twins in 2014. There he found more playing time at his natural shortstop position and made his first All-Star team in 2016. Then he was traded to the Giants a few weeks later. Nunez has played almost as much third base as he has shortstop over his eight-year major league career. In addition to second base, he has also played left field, right field and designated hitter.

To make room for Nunez on the 40-man roster, the Red Sox designated right-handed pitcher Ben Taylor for assignment. Taylor was on the opening day roster last season and posted a 5.19 ERA in 17 1/3 relief innings.