The 19-year-old is one of the few success stories at the Emirates Stadium this season in what has been an otherwise turbulent campaign on and off the pitch.
Martinelli was signed from Brazilian side Ituano last summer and he has impressed with his performances and work ethic, making 26 appearances in all competitions and scoring 10 goals.
He is the first Arsenal teenager to record double figures for goals in a season since Nicolas Anelka in the 1998/1999 season.
Martinelli is the second Arsenal teenager to sign a new long-term contract this week after Bukayo Saka.
"I am very happy that Gabi has signed a new contract with us," Gunners head coach Mikel Arteta said.
"He is a very talented young player and he has impressed us with his performances, attitude and work-rate. We are looking forward to getting him back to full fitness and to watching his development at our club."
Martinelli posted on Instagram: "I am very happy to commit my future to this great club and I would like to thank Arsenal and all the fans for this fantastic year.
"It is the first of many and I can't wait to be back to play a part in the exciting seasons to come!
"'Play for the name on the front of the shirt and they'll remember the name on the back.' @tonyadamsofficial."
Martinelli is yet to play for Arsenal since football resumed after the coronavirus pandemic as his season has been curtailed with a knee injury.