Story of Ganesha, demon Analasur and durva grass is found in the Puranas. When ignorance overcomes divinity, asur thinks himself to be the most powerful. Analasur became strong and powerful and started harassing all living beings on earth.
Devas, Rishis, humans and all other living beings in the universe approached Shiva and asked to put an end to the rule of Analasur on earth.
Shiva asked them to approach Ganesha as only he had the power to annihilate Analasur.
The living beings then approached Ganesha, who readily agreed to put an end to the tyranny of Analasur.
Ganesha asked Analasur to stop all Adharmic activities. But the demon did not listen to Ganesha and challenged him to battle
It was impossible to defeat Analasur using weapons. He was invincible to weapons.
Ganesha then thought of idea and challenged Analasur for a fist fight.
While the wrestling was underway, Ganesha opened his big mouth and swallowed Analasur. The agni in the stomach of Ganesha killed Analasur.
All living beings were happy but Ganesha showed signs of uneasiness due to indigestion.
Sage Kashyapa then offered 21 durva grass to Ganesha.
Ganesha ate the durva grass and immediately it helped in curing his indigestion and stomach ailments.