The discourse of Bhagavad Gita took place just before the start of the Kurushektra war.
After several attempts at reconciliation failed, war was inevitable. Out of pure compassion and sincere love for His devotee and best friend, Arjuna, Lord Krishna decided to become his charioteer during the battle. The day of the war finally came and both armies gathered on the battlefield face to face. Just as the battle was about to start, Arjuna asks Lord Krishna to drive the chariot to the middle of the battlefield in between both armies to have a look at the opposing armies. Seeing his Grandsire Bhishma who raised him with great affection since childhood, and his teacher Dronācārya who have trained him to become the greatest archer, Arjuna's heart begin to melt. His body started to tremble and his mind got confused. He became unable to perform his duty as a Kshatriya (warrior). He felt weak and sickened at the thought that he would have to kill his relatives, his friends and revered persons in this confrontation. Being very despondent, he told his friend Krishna of his sudden change of heart, and turned to Him for advice. The conversation that ensued, Lord Krishna's advice and teachings to Arjuna, is what is known now as the Bhagavad Gita, the most ancient scripture and non-sectarian philosophical work known to man.