Brahmarshi Vishvamitra (visva-mitra) is one of the most venerated rishis or sages of ancient India. He is also credited as the author of most of Mandala 3 of the Rigveda, including Gayatri Mantra. The Puranas mention that only 24 rishis since antiquity have understood the whole meaning of—and thus wielded the whole power of—Gayatri Mantra. Vishvamitra is supposed to be the first, and Yajnavalkya the last.

The story of Vishvamitra is narrated in the Balakanda of Valmiki Ramayana. Mahabharata adds that Vishvamitra’s relationship with Menaka resulted in a daughter, Shakuntala, whose story is narrated in Adi Parva of Mahabharata.

Vishvamitra was a king in ancient India, also called Kaushika (descendant of Kusha) and belonged to Amavasu Dynasty. Vishwamitra was originally the Chandravanshi (Somavanshi) King of Kanyakubja. He was a valiant warrior and the great-grandson of a great king named Kusha. Valmiki Ramayana, prose 51 of Bala Kanda, starts with the story of Vishvamitra:

There was a king named Kusha (not to be confused with Kusha, son of Rama), a brainchild of Brahma and Kusha’s son was the powerful and verily righteous Kushanabha. One who is highly renowned by the name Gaadhi was the son of Kushanabha and Gaadhi’s son is this great-saint of great resplendence, Vishvamitra. Vishvamitra ruled the earth and this great-resplendent king ruled the kingdom for many thousands of years.

His story also appears in various Puranas; however, with variations from Ramayana. Vishnu Purana and Harivamsha chapter 27 (dynasty of Amaavasu) of Mahabharata narrates the birth of Vishvamitra. According to Vishnu Purana, Kushanabha married a damsel of Purukutsa dynasty (later called as Shatamarshana lineage – descendents of the Ikshvaku king Trasadasyu) and had a son by name Gaadhi, who had a daughter named Satyavati (not to be confused with the Satyavati of Mahabharata).

Satyavati was married to an old Brahmin known as Ruchika who was foremost among the race of Bhrigu. Ruchika desired a son having the qualities of a Brahmin and so he gave Satyavati a sacrificial offering (charu) which he had prepared to achieve this objective. He also gave Satyavati’s mother another charu to make her conceive a son with the character of a Kshatriya at her request. But Satyavati’s mother privately asked Satyavati to exchange her charu with her. This resulted in Satyavati’s mother giving birth to Vishvamitra, son of a Kshatriya Gadhi with qualities of a Brahmin and Satyavati gave birth to Jamadagni, father of Parashurama, a Brahmin with qualities of a Kshatriya.

Tapasya
Vishvamitra and Menaka, painting by Raja Ravi Varma.

This incident made a deep impression on the King. He realized that power obtained by penances was far greater than mere physical might. He renounced his kingdom and began his quest to become a greater rishi than Vashista. He took on the name Vishvamitra. Vishvamitra faced many challenges in his life to become a Brahmarishi, before eventually giving up the greed to possess the cow.
Vishwamitra Archery Training

After many trials and undergoing many austerities, Vishvamitra at last obtained the title of Brahmarishi from Vashista himself. During this time he had a daughter named Shakuntala(who appears in Mahabharata) with Menaka, an apsara in the court of Indra. Son of Shakuntala became a great emperor. He came to be known as Bharatha.
Alternative version

Kaushika seeks to attain the same spiritual power as Vashista, to become his equal, a brahmarishi. He undertakes a fierce penance for one thousand years, after which Brahma names him a Rajarishi or royal sage.

After another long penance of thousand years, Brahma names him a rishi, thus leaving his royal lineage permanently. And Brahma suggest him to take Bramharshi grade from his guru Vashista only as he only has the power to call you as Brahmarshi.
Birth of Shakuntala

At this point, Indra, the king of Swarga attempts to test the tapasvi by sending Menaka, an apsara to seek Kaushik’s hand in marriage. Kaushik then lives with Menaka for 10 years. They have a baby girl Shakuntala. Kaushik becomes angry when he realises Menaka’s true agenda had destroyed his years of meditation and thus he cursed her that she will not possess her beauty, of which she was proud, in next birth.

Kaushika now goes to the banks of the river Kaushiki, which is the spirit of his own sister.
Menaka and Vishvamitra

After many thousands of years of penance, Brahma names him maharishi, but also tells him that he has not become a jitendriya yet, lacking control over his passions. This is brought to light to Kaushika when he angrily curses Rambha, an apsara sent by Indra to foil Kaushika’s plan again, to become a stone for 1000 years.
Rise to Brahmarishi

After cursing Rambha, Kaushika goes to the highest mountain of Himalayas to perform an even more severe tapasya for over 1000 years. He ceases to eat, and reduces his breathing to a bare minimum.

He is tested again by Indra, who comes as a poor Brahmin begging for food just as Kaushika is ready to break a fast of many years by eating some rice. Kaushika instantly gives his food away to Indra and resumes his meditation. Kaushika also finally masters his passions, refusing to be provoked by any of Indra’s testing and seductive interferences.

At the penultimate culmination of a multi-thousand year journey, Kaushika’s yogic power is at a peak. At this point, Brahma, as the head of Devas led by Indra, names Kaushika a Brahmarishi and names him Vishvamitra or Friend of All for his unlimited compassion. He then goes to meet Vashishta. It was customary that, if a sage was greeted by an equal or superior person, the sage would also greet the person. If the sage was greeted by an inferior person, the sage would simply bless them. Initially, when Vishwamitra greeted Vashishta with the pride of being a new Brahmarishi in heart, Vashishta simply blessed him. Suddenly all pride and desire left Vishwamitra’s heart and he became a clean and clear brahmarishi. When Vishwamitra turned back to leave, Vashishta realised the change of heart and proceeded to greet Vishwamitra. Vishwamitra is also embraced by Vashista and their enmity is instantly ended.
Gayatri mantra

Vishvamitra is said to have found Gayatri Mantra. It is a verse from a sukta of Rigveda . Gayatri is the name of the Vedic meter in which the verse is composed.

Gayatri mantra is repeated and cited very widely in Vedic literature and praised in several well-known classical Hindu texts such as Manusmriti (“there is nothing greater than the Savitri (Gayatri) Mantra. Harivamsaand Bhagavad Gita. The mantra is an important part of the upanayana ceremony for young males in Hinduism and has long been recited by dvija men as part of their daily rituals. Modern Hindu reform movements spread the practice of the mantra to include women and all castes and its recitation is now widespread