The 18-year-old Germany youth forward scored his first senior goal for Arsenal in the 2-1 win at Swansea last month.
That goal came a week after he made his full Premier League debut in the leaders’ win over Stoke.
Gnabry came through the London club’s youth system and made his senior debut in last season’s 6-1 League Cup win over Coventry.
“We signed Serge Gnabry because I believe that he will be a great player,” Arsenal manager Arsene Wenger told the club’s website.
“He’s nearly there now, and competes for a regular place in the team in the Premier League.
“He has technical ability, he has power, he has pace, he has finishing quality and he can give a final ball. He’s a powerful offensive player and I believe that he will be a great player for Arsenal football club.”
Gnabry said: “Arsenal is a great football club and I’m so happy to be here and sign a new contract.
“For me, now it’s all about working hard and developing my game.
“I’ve had some good opportunities recently in the first team, which has given me extra confidence, and this will only improve my game. I’m looking forward to giving my best for this club in the years to come.”