In Shiva Mahapurana,Koti Rudra samhitha chapter it explained about how Trayambakeshwar Jyothirlinga emerged.
Gautham does penance to please varuna God
During the ancient time there lived a famous sage named Gautam. The name of his wife was Ahilya. Once it did not rain for one hundred years as the result of which the whole area was affected by drought. Sage Gautam did a tremendous penance to please Varun appeared before Gautam, he was requested to cause rain. But Varun expressed his inability in causing rain. He told Gautam to please lord Shiva so that his wish could be fulfilled. Later on Varun instructed Gautam to dig a up a pit, which he (Varun) filled with water. Varun blessed Gautam by saying that this pond would never dry up.
Disagreement between the wives of Sages
The sages who had abandoned that place returned there. Everybody became happy and satisfied. One day, sage Gautam instructed his disciples to fetch some water from that pond. When the disciples reached there, they found the wives of numerous sages present at the bank of the pond. The sages wives did not allow them to take water and instead they rebuked them. The disciples returned back to the hermitage and narrated the whole story to sage Gautam.
Ahilya pacified the angry disciples and went to the pond to fetch water. From that day onwards this became very daily routine. One day Ahilya met the wives of the sages. They tried to prevent her from fetching water. Not only that they went back to his respective hermitages and filled the ears of their husbands. All the sages became very angry.
Sages plan to drive away Sage Gautam
The sages with their powers created an illusion of cow. Cow entered the field of Gautam in which barley was being cultivated. He started grazing the barley crops. When Gautam saw the cow grazing crops, he tried to drive her out from the field by hitting a grass on her back. The illusion of cow died instantly. Gautam was very sorry for his act. Meanwhile all the sages from the surrounding area arrived there. They forced Gautam to abandon that place at once. Gautam left that place and made his hermitage at a little distance from there. One day he came to the sages and asked them as to how could he atone for his sins. The sages told him that his sins could be atoned only when Ganga water is sprinkeld on the cow so that the cow would come alive and to get rid of the sin killing a cow.
Sage Gautam made three crore parthiva Lingas as the part of Penance
Gautam then started a tremendous penance for which he made three crore Parthiva lingas as part of the penance.
Lord Shiva became very pleased by his devotion and appeared before him. Sage Gautam requested lord Shiva to liberate him from the sins of killing a cow. He also requested lord Shiva to manifest the stream of river Ganga that place. Lord Shiva made him understand that he was innocent and the real culprits were those wicked sages. At last lord Shiva instructed Ganga to appear in the form of a woman. Gautam eulogized Ganga. By the blessings of lord Shiva Gautam was liberated from his sins of killing a cow. After that Ganga expressed her desire to go back but lord Shiva asked her to remain on the earth till the twenty-eighth Manvantar. Ganga accepted to do that, on the condition that Lord Shiva along with Parvati too would remain present on the earth. Lord Shiva established himself as Trayambakeshwar Jyotirlinga and Ganga became famous as Gautami Ganga.