Mr Ansari is in a hospital in Dhanbad, saved by the timely arrival of the police, who fired gunshots to disperse the mob.
"Our men braved the crowd and immediately rescued Ansari and his family members. When the police tried to take him to hospital, there was resistance from the crowd. There was heavy stone-pelting. We had to open fire in the air," said a senior police officer RK Mullik.
Two men were injured, both in the legs, in the police firing and are in hospital too. About 50 policemen are also reported injured in the stone throwing.
Six people have been detained, Jharkhand Inspector General of Police (Headquarters) Ashish Batra told news agency Press Trust of India.
With incidents of cow vigilantism on the rise, union Law Minister Ravi Shankar Prasad said earlier this week that the government "is very clear that if anyone indulges in violence, then the law will have to do its job."
He was speaking about the murder of a 16-year-old boy Junaid Khan by a mob that accused him and his brothers of carrying beef in a train near Delhi.
In April, a Muslim dairy farmer was lynched in Rajasthan for allegedly smuggling cows.
Get the latest election news, live updates and election schedule for Lok Sabha Elections 2019 on ndtv.com/elections. Like us on Facebook or follow us on Twitter and Instagram for updates from each of the 543 parliamentary seats for the 2019 Indian general elections.