The 33-year-old has been without a club since leaving Crystal Palace at the end of the 2016-17 season.
According to Marca, Flamini will arrive in Vallecas 'in the coming days' as he looks to win a contract with Rayo, who currently play their football in the Segunda Division - Spain's second tier.
Flamini started his professional career with Marseille, before representing Arsenal between 2004 and 2008.
The three-time France international then spent five years with AC Milan, before returning for a second spell at Arsenal in 2013.
Flamini made just 10 Premier League appearances for Palace last season before being released on a free transfer.