Atheism originated as Charvaka or Barhaspatya sutras in Vedas

Athesim or Irreligion in ancient hinduism (dharma) was proposed by Brihaspati, the guru of devas. Vedas included this path of materialism as one of the ways of life. When vedas were segregated by Vyasa, these principals known as Bārhaspatya-sūtras (a patronymic of Brhaspati) were part of Rig Veda.
Atheism in Vedas
There is no rishi by the name Charvaka, but it is another name of Brihaspati. (Cara = agreeable, pleasant + vaka = speech).
It was also called Lokayata because it was prevalent (ayatah) among the people (lokesu), and meant the world-outlook of the people. Meaning of Lokāyata (लोकायत) signifies “directed towards, aiming at the world, worldly“.

Most of the primary literature of Bārhaspatya sūtras are lost. They were removed from Rig Veda at later periods (after Buddhism evolved), as buddhism at that stage was against vedic tradition and seers like Adi Sankaracharya tried to protect vedic culture by seperating all non-believing traditions out of it.
At later stages, more Charvaka principles were added from different Sastras, Ramayana, Mahabharata, Buddist and Jain preachings. Charvaka epistemology states that whenever one infers a truth from a set of observations or truths, one must acknowledge doubt; inferred knowledge is conditional.
It is the first atheist school in ancient India.
Charvaka or Barhaspatya SutrasThe name Lokāyata, for example, is found in Chanakya’s Arthashastra, which refers to three ānvīkṣikīs (अन्वीक्षिकी, literally, examining by reason, logical philosophies) – Yoga, Samkhya and Lokāyata.
However, Lokāyata in the Arthashastra is not anti-Vedic, but implies Lokāyata to be a part of Vedic lore. Lokāyata here refers to logic or science of debate (disputatio, “criticism“).

In Jaina literature, Saddarsanasamuccaya by Haribhadra, Lokayata is stated to be the Hindu school where there is “no God, no samsara (rebirth), no karma, no duty, no fruits of merit, no sin“.
Buddhist sanskrit text Divyavadana mentions Lokayata, where it is listed among subjects of study, and with the sense of “technical logical science“.
Shantarakshita and Adi Shankara use the word lokayata to mean materialism.

Few Charvaka atheistic doctrines can be traced to the relatively later composed layers of the Rigveda.
Ajita Kesakambali (अजित केशकंबली; Chinese: 無勝髮褐; pinyin: Wúshèng Fàhè) was an ancient Indian philosopher who was known to be the forerunner to the Charvaka school.
Lokayata also was meant Skepticism and its methodology of skepticism is included in the Ramayana, Ayodhya kanda, chapter 108, where Jabāli tries to persuade Rāma to accept the kingdom by using nāstika (athestic) arguments (Rāma refutes him in chapter 109):

स न अस्ति परम् इत्य् एव कुरु बुद्धिम् महा मते |
प्रत्यक्षम् यत् तद् आतिष्ठ परोक्षम् पृष्ठतः कुरु ||

Translation : O, the highly wise! Arrive at a conclusion, therefore, that there is nothing beyond this Universe. Give precedence to that which meets the eye and turn your back on what is beyond our knowledge. (2.108.17)

Charvaka’s epistemological argument can be explained with the example of fire and smoke. Kamal states, that when there is smoke, one’s tendency may be to leap to the conclusion that it must be caused by fire. While this is often true, it need not be universally true, everywhere or all the times, stated the Charvaka scholars. Smoke can have other causes.

Carvaka incident in the Mahabharata

A character described as a Carvaka briefly appears in the Mahabharata (in the Shanti Parva).
As Yudhishthira enters the city of Hastinapur, a brahmin, referred to as Carvaka, accuses him of killing his own kinsmen and says that he would suffer for it.
The accuser is revealed to a rakshasa in disguise, who was a friend of Duryodhana. He had existed since the Krita Yuga by virtue of a boon from the god Brahma, that he could only be killed when he is showing contempt towards brahmins. He was promptly killed by other brahmins by the chanting of sacred hymns and Yudhishthira was assured that his actions were the within the kshatriya code.
This event may be a possible denigration of the Carvaka philosophy.

In the 9th century CE, Jain philosopher Jinasena wrote the Mahapurana. The book contains the following often quoted words

Some foolish men declare that a creator made the world. The doctrine that the world was created is ill-advised, and should be rejected. If god created the world, where was he before creation? If you say he was transcendent then, and needed no support, where is he now ?

This quote was also featured later in Carl Sagan’s book, Cosmos.
In the 14th century, philosopher Madhavacarya wrote the Sarvadarśanasaṅ̇graha, which is a compilation of all Indian philosophies, including Carvaka, which is described in the first chapter.

Apart from Charvaka or Barhaspatya Sutras, Sāṃkhya (partially), Mīmāṃsā (meaning exegesis), Ājīvika (extinct since 13th century CE) are also Indian schools of Atheism or nāstika vādam.