All-Star infielder Mike Moustakas completed a $64 million, four-year contract Thursday with the Cincinnati Reds, the biggest free agent deal in franchise history.

They agreed to the deal earlier in the week. Moustakas was in town to sign it Thursday and get introduced at the team's annual fan festival.

The Reds have become active in free agency the last two years, trying to escape a rut of six straight losing seasons. They signed Moustakas from the NL Central-rival Brewers. The 31-year-old infielder will plug the Reds' hole at second base, which opened when Scooter Gennett got hurt and then was traded at midseason.

FILE - In this Aug. 18, 2019, file photo, Milwaukee Brewers third baseman Mike Moustakas throws the ball to first during a baseball game against the Washington Nationals in Washington. All-Star infielder Moustakas and the Cincinnati Reds have agreed to a $64 million, four-year contract, a person familiar with the negotiations told The Associated Press. The person spoke on condition of anonymity Monday, Dec. 2, 2019, because the agreement had not been announced. (AP PhotoNick Wass, File)

FILE - In this Aug. 18, 2019, file photo, Milwaukee Brewers third baseman Mike Moustakas throws the ball to first during a baseball game against the Washington Nationals in Washington. All-Star infielder Moustakas and the Cincinnati Reds have agreed to a $64 million, four-year contract, a person familiar with the negotiations told The Associated Press. The person spoke on condition of anonymity Monday, Dec. 2, 2019, because the agreement had not been announced. (AP PhotoNick Wass, File)

Cincinnati scored the fourth-fewest runs in the NL last season despite one of the league’s most hitter-friendly ballparks. Bulking up on offense is their top priority in the offseason.

“Mike is a proven performer on winning teams, and we are excited to add his power and experience to our roster," Reds owner Bob Castellini said.

Moustakas hit .254 with 35 homers and 87 RBIs last season and made the All-Star team for the third time. He has 42 games of playoff experience with the Royals from 2014-15 and the Brewers the last two seasons, which was attractive to a Reds team trying to get back to the postseason.

The Reds haven’t been to the playoffs since 2012, when they won 90 games and lost to the Pirates in the NL wild-card game. Cincinnati then launched into a rebuild, trading away stars for prospects. The team lost at least 94 games annually from 2015-18.

They decided to try to become competitive again last season and acquired Yasiel Puig, Matt Kemp, Alex Wood, Tanner Roark and Sonny Gray, who became an All-Star. Puig, Kemp and Roark were dealt during the season. Cincinnati finally escaped last place, finishing ahead of Pittsburgh with a 75-87 mark, wasted a lot of solid pitching along the way.

It's Moustakas' third stop in three years. He rejected a $17.4 million qualifying offer from Kansas City after the 2017 season but eventually returned to the Royals on a one-year deal. He was traded to the Brewers that July and finished with a .251 batting average, 28 homers and 95 RBIs.

He had a $7 million salary this year and gets a $3 million buyout for declining his $10 million option. He’s made $18.7 million on a pair of one-year deals the last two seasons.

More AP MLB: https://apnews.com/MLB and https://twitter.com/AP_Sports