About two thousand six hundred years ago, a group of monks (Buddha’s initiates), after getting the initiation from Buddha went to the Himalayan forest to practice deep meditation. Upon arriving at the forest, each monk found a large tree for themselves and they settled down under the tree for meditation
However, they started meditation without giving respect or asking permission from the tree spirits or beings living there. As the monks practice intensified, the tree spirits could not stay on their abodes on the tree as they were disturbed by the heat of the monks practice.
This forced the tree spirits to come down to the ground to investigate. Realizing what’s happening at the bottom of their tree, the tree spirits started to scare the monks away by harassing and torturing them in various ways.
After sometimes, the monks could not bear it any longer and went back to Buddha for help. It is upon hearing their story that Buddha taught the monks the loving kindness discourse (also known as Karaniya Metta Sutta) which is a preliminary meditation technique to permeate love to all beings.
The monks went back to the forest after receiving the discourse and started permeating the entire area with loving kindness to all the beings living there in the forest. The tree spirits were pleased with the love they were receiving and let the monks practice without disturbing them anymore.
Loving kindness meditation was developed based on this Metta sutta as taught by Buddha. Loving kindness meditation is not a meditation by itself but a preliminary exercise done prior to entering the actual meditation.