Terms of the deal were not made public, but multiple outlets reported that the agreement is worth about $95 million with $65 million guaranteed.
"We got him until he's 108," Giants general manager Dave Gettleman quipped. "I never worried whether or not we would get it done. I'm pleased, because the litmus test for a contract is that neither side is ticked off before the ink can dry, and neither side should be ticked off. It's a very fair deal."
The extension was announced 13 days before the Giants open their 2018 season at home against the Jacksonville Jaguars.
Beckham's $19 million average salary would top the $17 million earned by Antonio Brown of the Pittsburgh Steelers. His $95 million deal also tops the $82.5 million deal receiver Mike Evans has with the Tampa Bay Buccaneers.
Beckham, who missed most of last season with a broken left ankle, was scheduled to make $8.4 million in the final year of his rookie contract.
Beckham had said early in training camp that he was taking a risk practicing without a new contract. It paid off.
"Honestly, I don't even know how to explain it," Beckham said in a statement. "I don't know if it's a relief, I don't know -- it's a combination of everything. You've worked all your life to get to this point and it's finally here."
Beckham felt getting a new deal would be just a matter of time.
"I knew that it would get done, it just was a matter of when and I'm just so happy that it is finally done now," he said.
In his first four seasons, Beckham has caught 313 passes for 4,424 yards and 38 touchdowns.
Beckham has not played in any of the Giants' three preseason games as new coach Pat Shurmur has taken a very cautious approach with the catalyst to his offense coming off his first major professional injury.
A lot has been written about Beckham's contract situation since the end of last season. There were reports the Giants were involved in trade talks with the Rams and many wondered whether co-owners John Mara and Steve Tisch wanted to spend a lot of money on a player who also created some disturbing news off the field.
Beckham annoyed many by going to Florida for a boat outing with teammates before a playoff game after the 2016 regular season. He then played poorly in a one-sided loss to the Packers.
His reputation took another hit when a video was posted with him in a room where a hand-rolled cigarette was visible. A woman next to him had unidentified white powder on a nearby table.
During this past offseason, Beckham seemed to mature. He worked hard to overcome his injury, stayed out of trouble and developed a good relationship with Shurmur. He also said all the right things when asked about getting a new contract.
Beckham's agent Zeke Sandhu spoke with assistant general manager Kevin Abrams for almost two hours on the patio overlooking the field during a practice earlier this month.
The Associated Press contributed to this report.