Marcelo signed a deal until December 2024 with an option to extend until the end of 2025, the club said.
"Your home is and always will be Flumimense, @MarceloM12," the club wrote on Twitter alongside a video showcasing a cross-section of Marcelo's career.
"It's difficult to express what this moment means to me. I've been dreaming of returning to my origins for many years, to the team that trained me and taught me what I know about football," Marcelo told the club website.
Marcelo, 34, started both his youth and professional career at Fluminense. He made a switch from the Brazilian side to Madrid back in 2007, and went on to make 546 appearances during 15 seasons for the Spanish champions.
He left the Bernabeu in the close season as the most decorated player in the club's 120-year history with 25 trophies -- including five Champions League titles.
Olympiakos announced Marcelo's departure on Saturday, as the player terminated his contract five months after joining in September.