The 37-year-old moves to the United States after two seasons with Al Sadd in Qatar, and will join for the 2015 league campaign, while also working with the team's youth academy.
Raul is one of the most decorated players in Real history after making 741 appearances for the club following his debut as a 17-year-old, while also breaking the club goalscoring record in La Liga and all competitions.
His 71 goal record in the UEFA Champions League is also a competition record, although Cristiano Ronaldo and Barcelona's Lionel Messi are closing in on that tally.
Since leaving the Spanish capital Raul has also played in Germany with Schalke, but now he is set for a career in America and head coach Giovanni Savarese is delighted to have him on board.
"We're obviously thrilled to add a player of his quality to the team," he told the Cosmos' official website. "Raul's skill and ability is world renowned. He's a world-class player and he adds a whole new dimension to our attack.
"He also brings immense passion and knowledge that he can share with our team and with the next generation of Cosmos players in our youth academy.
"He'll help set the academy training curriculum, structure and establish our player development pyramid."
Upon his retirement from playing, Raul - who joins former Spain colleague Marcos Senna in New York - will assume a full-time role with the Cosmos' academy.
Thank you for reading 5 articles this month* Join now for unlimited access
Enjoy your first month for just £1 / $1 / €1
*Read 5 free articles per month without a subscription
Join now for unlimited access
Try first month for just £1 / $1 / €1