Flamini initially left Arsenal in 2008 when he refused to sign a new contract and joined AC Milan, where he won a Serie A title in 2011.
The France international made 22 appearances for Milan last season but left the club when his contract expired.
Having been given permission to train with his former club this summer, Flamini has made a sufficient impression on Arsene Wenger to win a contract – reportedly for as much as three years.
"We’re very pleased Mathieu has agreed to re-join us," Wenger said. "He is a player of real quality, with a fantastic work rate and great mentality.
"As we know, Mathieu is a strong midfielder, but is also is comfortable playing in defence too. He is a very good addition to our squad."
Flamini is Arsenal's second signing of the summer following another free transfer acquisition in striker Yaya Sanogo.
Originally brought to Arsenal on another free transfer in 2004, Flamini made 153 appearances during his first spell in North London, famously playing as a makeshift left-back in the run to the Champions League final in 2006.
However, it was as a midfielder that he really made his mark in the 2007-08 campaign, forming an excellent partnership with Cesc Fabregas in the heart of the Arsenal team.