Mahishasura's father Rambha was king of the asuras, traditional enemies of the devas (Hindu gods) and he once fell in love with a water buffalo ( which was in reality a cursed Princess Shyamala); Mahishasura was born out of this union (part of his name translates into buffalo) - as a result of this unorthodox union he could take form of either man or buffalo at will.
Despite the asura being (on the whole) power-seeking deities with no real ethics outside conquest he was pious in his meditation to Brahma and eventually Brahma rewarded him by granting him a powerful gift "boon that he could not be defeated in battle by any man or god".
Mahishasura, true to his asura nature, was quick to abuse Brahma's gift and invaded heaven, defeating Indra (the king of gods) and driving all the devas out of heaven.
The devas assembled to decide what to do about the invincible asura and they decided that since he was invincible to all men the only way to defeat him was to create a young woman called Durga, empowered by the strength of all the devas - Durga proceeded to gather an army to fight against Mahishasur and his evil minions, who had began a reign of terror on both heaven and earth.
After nine days of fighting Durga finally reached Mahishasura and by the tenth day the asura had been slain by the goddess and peace was restored to the world.