The legend of Shiva Linga or Lingodbhavamurthy is deeply related to Mahashivaratri. The legend narrates the story of vain search by Brahma and Vishnu to discover the Aadi (beginning) and the Antha (end) of Lord Shiva. The legend thus proves the supremacy of Lord Mahadeva over other Hindu Gods and explains why the lingam is believed to be one of the most potent emblems in Hindu ideals. The story is stated in the three of the puranas - the Kurma Purana, the Vayu Purana and Shiva Purana
According to Puranas, once the other two of the triads of Hindu Gods,
Brahma and Vishnu were fighting over each others prowess.
Horrified at the intensity of the battle, the other gods asked Shiva to
intervene. To make them realize the futility of their fight, Lord Shiva
assumed the form of a flaming Linga in between Brahma and Vishnu and
challenged both of them by asking them to measure the gigantic Linga
(phallic symbol of Lord Shiva).
Awestruck by its magnitude, Brahma and Vishnu decided to find one end
each to establish supremacy over the other. Lord Brahma took the form of
a swan and went upwards while Lord Vishnu assumed the form of Varaha - a
boar and went into the earth towards nether land. Both searched for
thousands of miles but neither could find the end.
On his journey upward, Brahma came across Ketaki flower.
Exhausted and bewildered with his search to find the uppermost limit of
fiery column, Brahma made Ketaki assent to lie that he had seen the top
of the column where the flower had previously resided. Accompanied by
his accomplice, Brahma confronted Vishnu and asserted that he had indeed
discovered the origin of the cosmic column.
At this point, the central part of the pillar split open and Shiva
revealed himself in his full glory. Overawed, both Brahma and Vishnu
bowed before him accepted lord Shivas supremacy. Lord Shiva also
explained to Brahma and Vishnu that both of them were born out of him
and that the three were then separated out into three different aspects
However, Lord Shiva was angry with Brahma for making a false claim. The
Lord cursed Brahma that no one would ever pray to him. (This legend
explains why there is hardly any Brahma temple of significance in
India.) Lord Shiva also punished the Ketaki flower for testifying
falsely and banned her from being used as an offering for any worship.
Since it was on the 14th day in the dark fortnight of the month of
Phalguna that Shiva first manifested himself in the form of a Linga, the
day is extremely auspicious and is celebrated as Mahashivaratri -
the grand night of Shiva. To celebrate the occasion, devotees of Lord
Shiva fast during the day and pray to the Lord throughout the night. It
is said that worshipping of Lord Shiva on Shivaratri bestows one with
happiness and prosperity.