Terms of the deal were not released Saturday.
The 5-foot-11, 220-pound Gaffney is a potential long-term replacement for DeAngelo Williams and Jonathan Stewart.
The Panthers like his athleticism and general manager Dave Gettleman has praised his ability to pick up the blitz.
Gaffney left Stanford in 2012 to play in the Pittsburgh Pirates minor league system. He hit .297 in 38 games, but said he missed football and decided to return to Stanford for his senior season.
In 2013, he won the starting job and ran for 1,709 yards with 21 touchdowns.
AP NFL website: www.pro32.ap.org and www.twitter.com/AP-NFL