In the received vulgate the Gita occupies chapters 23 to 40 of the Bhishma Parva, the sixth of the epic's eighteen books, interrupting the battle narrative for eighteen chapters and then resuming it. That position is the crux of the dating problem.
Most textual scholars place its composition somewhere between the second century BCE and the second century CE, later than the epic's oldest layers and earlier than its final form. The evidence is internal: the Gita knows Samkhya categories and yoga practice in developed form, deploys a vocabulary of devotion to a personal God that the surrounding narrative does not, and argues about the relative value of ritual, renunciation and action in terms that read as a response to established Buddhist and Jain positions. Whether it was composed for its place, inserted whole from elsewhere, or assembled in stages within the epic is unsettled. The chapter break at the end, where the battle simply resumes, is easily read either way.
Hindu tradition holds the whole Mahabharata, Gita included, to be the composition of Vyasa, and treats the discourse as spoken as reported. The two accounts are not reconcilable and both are worth stating plainly.
The verse count is itself evidence. Seven hundred is the traditional figure, and the number Shankara worked from around 800 CE. The Kashmirian recension that Abhinavagupta commented on in the tenth or eleventh century carries additional verses, giving a total near 745, and differs in wording at many points besides. The Pune critical edition of the Mahabharata prints 700. That a text so closely memorised and so heavily commented on still varies by fifteen verses across regions is a useful corrective to any assumption that Indian scripture was transmitted uniformly, the Vedic recitation schemes protected the Vedas, not the epics.