Mr Ansari polled 490 of the valid votes cast today. His opponent, the NDA's Jaswant Singh, a BJP leader and former Union Minister, got only 238. Eight votes were found invalid.
A total 788 Lok Sabha and Rajya Sabha MPs were eligible to vote today. Mr Ansari's poll managers had said they expected him to get at least 500 of those, he came close with his 490. He would have needed 396 to win, a number reduced by abstentions - 34 MPs abstained, 21 of the Biju Janata Dal, 11 of the TDP and two of the RSP.
All partners in the ruling alliance were on board to support Mr Ansari's candidacy. Parties like Mulayam Singh Yadav's Samajwadi Party, Mayawati's Bahujan Samaj Party and Lalu Yadav's RJP readily supported him too. As did two Left parties.
Jaswant Singh, who was also supported by the AIADMK, was cheerful till the end. He said as voting began this morning, "We know how many Kauravas were there and how many Pandavas were there and who won ultimately."
Attendance was high today. By 1 pm, about 600 MPs had already voted. By 5 pm, end of voting, there were reports that almost all MPs had turned up to cast their secret ballot. Prime Minister Manmohan Singh, Sonia Gandhi and Rahul Gandhi voted early. Union Minister Vilasrao Deshmukh could not vote. He is critically ill.
New MP and actor Rekha voted as did Sachin Tendulkar, dapper in a pin-striped shirt.