Sources told ESPN that 30-year-old Ayers will get $19.5 million -- of which $10.5 million is guaranteed -- and could reach $21 million with incentives.
"Robert is a versatile pass rusher who can play a variety of positions along the defensive line and has been successful both from the interior as well as the edge," Buccaneers GM Jason Licht said in a statement. "... [He] is an ideal fit for our 4-3 defensive system.
"Experienced pass rushers who can provide consistent pressure and disrupt an opponent's passing game are critical to our defensive success and Robert will do all those things, along with providing veteran leadership."
Ayers was the first-round pick of the Denver Broncos in 2009 and collected just 12 sacks in his five years with that team. He signed with the Giants as a free agent before the 2014 season.
In his two seasons with the Giants, Ayers had 14.5 total sacks, including 9.5 in 2015.
He missed four games each year to injury, but he finished this past season especially strong. His play at defensive end improved dramatically once he was healthy and Jason Pierre-Paul returned from his fireworks accident.
Ayers had 7.5 sacks in his final five games of the season.
ESPN Giants reporter Dan Graziano contributed to this report.