Hamburg sign Van Nistelrooy
"The 33-year-old striker gets a contract until June 30, 2011," the club announced on their website.
Van Nistelrooy added: "I am very happy that it worked out and look forward to Monday when I will arrive in Hamburg.
"Hamburg is a fantastic club with a strong team and great ambitions. I also have great ambitions."
Hamburg are fifth in the league on 34 points from 19 matches, five off the top.
Van Nistelrooy played 68 games for Real since 2006, scoring 46 goals. He has also been capped 64 times by Netherlands.
The striker, who has also played for Manchester United and PSV Eindhoven, has not played in the last two months due to a muscle injury.
Van Nistelrooy was a central figure in Real Madrid's two title-winning seasons in 2007 and 2008, but needed surgery to repair damaged cartilage in his right knee late in 2008 that put him out for the rest of that campaign.
Hugely popular with Real fans, he returned to action at the start of the current season but found his chances limited with the arrival of Karim Benzema and Cristiano Ronaldo, to bolster Real's existing frontline of Gonzalo Higuain and Raul.
"Real's behaviour was super," said the player. "They put no obstacles in my way. I had a great time in Madrid."
Van Nistelrooy is desperate to get matches under his belt, especially after falling down the pecking order at Real, as he eyes a spot in the Netherlands World Cup squad for this year's finals.
"Ruud has shown his qualities at top international clubs," said Hamburg coach Bruno Labbadia. "I am convinced he will score important goals for Hamburg as well."