The story of the goddess Kali is told in the Devi Mahatmya of the Markandeya Purana. She is an incarnation of the goddess Durga. Durga was created from the combined powers of Brahma, Vishnu, and Shiva in order to defeat the demon Mahishasura. But she is generally viewed as the consort of Shiva, because she is considered an incarnation of Shiva’s wife Parvati. (Or if you’re a follower of the Shakti sect, then you’d view Durga to be a manifestation of the same Adi Parashakti of which Shiva’s wives Shakti and Parvati were both incarnations.)
In any case, the story of Kali happened after Durga’s victory over Mahishasura. Once the demons Shumba and Nishumba defeated the gods in battle and took over the three worlds, so the gods went to mount Kailash to ask Durga for help. After they said a prayer to Durga, Shiva’s wife Parvati came by, and out of her body came a form of Durga known as Ambika or Kaushiki. During Ambika’s battle with the Shumba and Nishumbha’s Asura army, she was confronted by a pair of Asura generals named Chanda and Munda. To defeat them, Ambika created Kali out of her forehead, as described in this chapter of the Devi Mahatmya of the Markandeya Purana:
Thereupon Ambika became terribly angry with those foes, and her anger her countenance then became dark as ink. Out from the surface of her forehead, fierce with frown, issued suddenly Kali of terrible countenance, armed with a sword and noose. Bearing the strange skull-topped staff, decorated with a garland of skulls, clad in a tiger’s skin, very appalling owing to her emaciated flesh, with gaping mouth, fearful with her tongue lolling out, having deep-sunk reddish eyes and filling the regions of the sky with her roars, and falling upon impetuously and slaughtering the great asuras in that army, she devoured those hosts of the foes of the devas.
In brief one has to activate the kali energy in one’s self to overcome all the lust and greed which blemishes our divine soul.
OM KRIM KALIKAYA NAMASTUTE