The deal is worth a total of $206 million, a source told ESPN's Pedro Gomez.
Sources familiar with Greinke's negotiations told ESPN's Jerry Crasnick that Greinke had been seeking a deal with an average annual value of $31.5 million or $32 million, slightly higher than the $31 million a year that David Price commanded in his seven-year, $217 million contract with the Boston Red Sox.
While Price's deal with Boston includes an opt-out after three years, there is no opt-out in Greinke's agreement, a MLB source told Crasnick.
With their late push, the Diamondbacks spirited Greinke away from their top two division rivals, the Los Angeles Dodgers and San Francisco Giants, both of whom made signing him a top priority this offseason.
Greinke, 32, led the major leagues this past season with a 1.66 ERA, the lowest in 20 years, and an 0.84 WHIP, teaming with Clayton Kershaw to give the Dodgers one of the greatest one-two pitching punches in baseball history. Despite those two starting four of the five games against the New York Mets, however, the Dodgers lost the National League Division Series in five games, with Greinke taking the loss in Game 5.
He finished second in NL Cy Young Award voting behind Jake Arrieta of the Chicago Cubs.
In November, Greinke opted out of the remaining three years and $71 million of a contract he signed with the Dodgers in the winter of 2012.
"We made a very strong offer to retain Zack but clearly he found a deal that fit better for him and his family," Dodgers president of baseball operations Andrew Friedman said in a statement Friday. "We are now hard at work on our alternatives. We wish Zack, Emily and Bode all the bet going forward."
The Dodgers' final offer was for five years, a source said.
The $34.3 average annual value of Greinke's contract is the most ever for a pitcher, topping the $31 million average annual value of Priceand Detroit Tigers slugger Miguel Cabrera, according to ESPN Stats & Information. Kershaw's contract extension with the Dodgers in 2014 was for $215 million ($30.7 million), and Max Scherzer signed a seven-year, $210 million deal with the Nationals last winter ($30 million).
Greinke's contract of $206 million is larger than all the major league free-agent contracts the Diamondbacks handed out in the previous eight offseasons combined ($201.725 million for 28 players), according to ESPN Stats & Info.
Arizona entered the offseason on a mission to find a No. 1 starter to lead a young rotation that includes Patrick Corbin, Rubby De La Rosa, Robbie Ray and Chase Anderson. In November, a delegation led by team president Derrick Hall, chief baseball officer Tony La Russa and general manager Dave Stewart traveled to the Dominican Republic to make an offer to free-agent right-hander Johnny Cueto. But when Cueto spurned the Diamondbacks' six-year, $120 million offer, Arizona management was forced to re-assess. The team's revised game plan led to Greinke.
Arizona finished third in the NL West this season with a 79-83 record. But the Diamondbacks have a solid position-player core headed by first baseman Paul Goldschmidt, who finished second to Bryce Harper in the NL MVP race, and center fielder A.J. Pollock, who made the All-Star team and won a Gold Glove and a Silver Slugger Award this season.
The Greinke signing is a major step toward upgrading an Arizona pitching staff that ranked ninth in the league with a 4.04 ERA in 2015.
A Florida native, Greinke won the 2009 American League Cy Young award with the Kansas City Royals before a 2010 trade to the Milwaukee Brewers.
A candid, somewhat reclusive personality, Greinke missed most of the 2006 season with what the Royals later described as social anxiety disorder.
Last season, Greinke began drawing comparisons to Hall of Famer Greg Maddux because of his brilliant command, excellent changeup and his Gold Glove-level fielding ability. He also is one of the best pitchers in baseball at hitting. He batted .224 with two doubles and two home runs last season.
In 12 big league seasons, Greinke is 142-93 with a 3.35 ERA.
ESPN's Jerry Crasnick, Jim Bowden and Mark Saxon contributed to this report.
Kurkjian on Greinke: Stunning, no one saw this coming
Tim Kurkjian reacts to Zack Greinke signing a six-year deal with the Diamondbacks.