The 24-year-old has been a key component at the back for Mikel Arteta's side since signing from Lille for €30m in the summer of 2020.
Gabriel has tallied 81 appearances and scored nine goals for Arsenal.
This season he has formed a formidable partnership with William Saliba in the heart of defence, with Arsenal sitting four points clear at the top of the Premier League table and into the knockout stages of the Europa League.
An Arsenal statement read: “Gabriel Magalhaes has signed a new long-term contract with us.
“Everyone at the club would like to congratulate Gabi on his new contract and look forward to his continued contribution.”
Speaking of the news, boss Arteta remarked: “Gabi has shown huge qualities since he joined us.
“He is a young player with a great work ethic and his consistent strong performances have been hugely important to us over the past two seasons.
“Working with Gabi every day is a pleasure, he has formed strong relationships with everyone at the club and we’re so pleased that he has committed to us on a long-term contract.”
Technical director Edu added: “It’s great that we’ve agreed a new deal with Gabi. At 24, he’s still a young player and is part of our future.
“His performances since he joined us in 2020 have been very strong and his positive impact to our results have been clear for everyone to see.
“He has grown so much on and off the pitch, with both his contribution and communication on and off the pitch.
“We all look forward to see Gabi continue to grow as an important part of our club.”
Gabriel is yet to be capped at international level for the Brazil national team.