The Boston Red Sox hired John Farrell as their next manager, the team announced Sunday afternoon. It is a three-year deal.

"I'm extremely excited to be returning to the Red Sox and to Boston," Farrell said via a team news release. "I love this organization. It's a great franchise in a special city and region, with great fans, and we want nothing more than to reward their faith in us."

Farrell, Boston's former pitching coach, had one year remaining on his contract as manager of the Toronto Blue Jays.

As compensation, the Red Sox will send veteran infielder Mike Aviles to Toronto and will receive right-handed pitcher David Carpenter.

"We are thrilled to name John Farrell as our new manager," Red Sox general manager Ben Cherington said in a statement. "John has been a major league pitcher, front office executive, coach, and manager. His broad set of experiences, and exceptional leadership skills, make him the ideal person to lead our team. I have known him in various capacities throughout my career, and I hold him in the highest regard as a baseball man and as a person."

Red Sox left-hander Jon Lester wasn't waiting.

"Welcome back John!!" Lester tweeted Sunday morning. "Can't wait to get back to work!!"

Aviles also issued a statement via Twitter on Sunday.

"Wanna thank #RedSoxNation for all the support, great city, team and fans!" Aviles posted on the social media site. "Loved my time there but now it's time for a new chapter! #gojays"

The Red Sox formally interviewed four candidates -- Los Angeles Dodgers third-base coach Tim Wallach, New York Yankees bench coach Tony Pena, San Diego Padres special assistant Brad Ausmus and Baltimore Orioles third-base coach DeMarlo Hale -- to replace Bobby Valentine, but Farrell had been "at the top of their list" from the start, a team source told ESPNBoston.com earlier this month.

Farrell served as the Red Sox's pitching coach from 2007 through 2010.

The Red Sox attempted to acquire Farrell a year ago, but they weren't willing to bow to Toronto's asking price of what was rumored to be pitchers Clay Buchholz and/or Daniel Bard.

The Red Sox eventually hired Valentine, then fired him the day after finishing their worst season (69-93) in more than four decades.