Zack Greinke will still pitch in the NL West. But surprise — with the Arizona Diamondbacks.

The Diamondbacks unexpectedly won the Greinke sweepstakes, beating out the rival Los Angeles Dodgers and San Francisco Giants for the free-agent ace Friday night. He reached agreement on a $206.5 million, six-year deal, sources told the Associated Press.

The major league ERA leader and runner-up for the NL Cy Young Award boosted the Dodgers to their third straight division title this season. Then the 32-year-old righthander opted out of his contract, leaving $71.5 million on the table — and wound up with the richest deal, by yearly average, in baseball history.

The sources spoke to the AP on condition of anonymity because there hadn't been an official announcement. Fox first reported an agreement.

Greinke was the second former AL Cy Young winner to get a mega-contract this week. David Price joined the Boston Red Sox for $217 million over seven years. The moves came as teams prepared to head this weekend to the winter meetings in Nashville, Tenn.

Greinke's new deal contains deferred money. The $34.4 million average will be the sport's highest, topping Price's $31 million.

Earlier this offseason, pitcher Johnny Cueto turned down a $120 million offer from the Diamondbacks after he helped Kansas City win the World Series and became a free agent.

Instead, the Diamondbacks reeled in an even bigger prize. They had money to spend — last February, they signed a TV deal with Fox Sports Arizona for more than $1.5 billion over 20 years.

Greinke's contract gave him the flexibility to find a new home. He was in prime position, too, after setting a career high for wins by going 19-3 and posting a 1.66 ERA that was the best in the majors in 20 years.

Pelfrey goes to Tigers

Free-agent righthander Mike Pelfrey, who was 6-11 with a 4.26 ERA with the Twins last season, reached a $16 million, two-year agreement with the Detroit Tigers, according to a person with knowledge of the deal.

The person spoke on condition of anonymity Friday because the deal, which was still subject to a successful physical, had not been announced. Pelfrey, 31, would join a Detroit rotation bolstered by the signing of righthander Jordan Zimmermann less than a week ago.

Pelfrey is the second significant free agent to leave the Twins this offseason. Outfielder Torii Hunter retired.

Bonds a Marlins coach

Steroids-tainted home run king Barry Bonds is returning to baseball full time as hitting coach for the Miami Marlins.

He'll join the staff of new manager Don Mattingly, the Marlins said Friday.

Bonds made a rare conference call appearance to discuss his hiring, which raised his profile just as balloting is under way for 2016 Hall of Fame voting.

"I'm a Hall of Fame baseball player with no doubt in my mind, no doubt in my heart," said Bonds, 51. "God knows that. That's all that matters to me. I'll leave the voting process up to you guys."

Bonds, 51, ended his playing career in 2007 and has worked in recent years as a guest instructor for the San Francisco Giants in spring training. He's the career leader in home runs with 762.

Cubs land Lackey

The Chicago Cubs took a major step toward fortifying their starting rotation Friday by agreeing to terms on a two-year contract with free agent John Lackey.

A source confirmed the agreement, which is valued between $32 million and $34 million, according to a tweet by Ken Rosenthal of Fox Sports. The agreement will become official once Lackey passes a physical examination.

Lackey, 37, has won 165 games during a 13-year career. He posted a 2.77 ERA in 33 starts for the St. Louis Cardinals in 2015 and has an 8-5 postseason record. He will be reunited with lefthander Jon Lester and catcher David Ross, who were his teammates on the 2013 Boston Red Sox team that won the World Series.

The signing will cost the Cubs their first pick in the 2016 draft.