During the guruship of Guru Nanak Dev, collections of his holy hymns were compiled and sent to distant Sikh communities for use in morning and evening prayers. His successor Guru Angad Dev began collecting his predecessor's writings. This tradition was continued by the third and fifth gurus as well. When the fifth guru Guru Arjan Dev was collecting religious writings of his predecessor, he discovered that pretenders to the guruship were releasing what he considered as forged anthologies of writings of the previous guru and including their own writings with them] In order to prevent spurious scriptures from gaining legitimacy, Guru Arjan Dev began compiling a sacred scripture for the Sikh community.
He finished collecting the religious writings of Guru Ram Das, his immediate predecessor, and convinced Mohan, the son of Guru Amar Das, to give him the collection of the religious writings of the first three gurus.In addition, he sent disciples to go across the country to find and bring back any previously unknown religious writings of theirs. He also invited members of other religions and contemporary religious writers to submit writings for possible inclusion. Guru Arjan pitched a tent by the side of Ramsar tank in Amritsar and started the task of compiling the holy Granth. He selected hymns for inclusion in the Adi Granth and Bhai Gurdas acted as his scribe.
While the holy hymns and verses were being put together Akbar, the Mughal Emperor, received a report that the Adi Granth contained passages vilifying Islam. Therefore, while travelling north, he stopped en route and asked to inspect it. Baba Buddha and Bhai Gurdas brought him a copy of the Adi Granth as it existed then. After choosing three random passages to be read, Akbar decided that this report had been false.
In 1604, Adi Granth was completed and installed at the Harmandir Sahib, with Baba Buddha as the first granthi, or reader.[Since communities of Sikh disciples were scattered all over northern India, copies of the holy scripture needed to be made for them.The sixth guru added the tunes of 9 out of 22 Vars. Seventh and eighth guru did not have writings of their own added to the holy scripture; however, the ninth guru, Guru Tegh Bahadur, did. The tenth guru, Guru Gobind Singh, included writings of his father Guru Tegh Bahadur in the Guru Granth Sahib, and included 1 salokh in mahala 9 Ang 1429.
In 1704 at Damdama Sahib, during a one-year respite from the heavy fighting with Aurangzeb which the Khalsa was engaged in at the time, Guru Gobind Singh and Bhai Mani Singh added the religious compositions of Guru Tegh Bahadur to Adi Granth to create a definitive compilation.Religious verses of Guru Gobind Singh were not included in Guru Granth Sahib, but he added 1 sloak in mahala 9 Ang 1429. His banis are found in the Sri Dasam Granth, they are part in the daily prayers of Sikhs During this period, Bhai Mani Singh also collected Guru Gobind Singh's religious writings, as well as his court poems, and included them in a secondary religious volume, today known as the Dasam Granth Sahib.