The 32-year-old midfielder, whose deal was due to expire in June, had been linked with Chelsea and Manchester City, as well as a return to Liverpool, but will now stay at the Bernabeu until 2016.
"This will continue to be my home for two more years. I am very happy to tell you. Come on Madrid!" he posted on his official Twitter account.
The La Liga side later confirmed on their website: "Xabi Alonso will continue with Real Madrid until 2016."
Alonso's start to the current campaign had been disrupted by a groin injury and a broken bone in his foot but since his return at the end of October, Carlo Ancelotti's side have gone 13 games unbeaten.
The World Cup winner's team-mates Fabio Coentrao, Angel Di Maria and Alvaro Morata have also been linked with January moves but Ancelotti said on Wednesday that movement neither in, nor out was expected.
When asked about the futures of Coentrao - linked with Manchester United - and Di Maria - thought to interest Arsenal - he said: "I've not spoken with them because there's nothing. No-one is leaving and no-one is coming in.
"We have a good squad. We don't need anything."