The canon of scripture has been a controversial topic ever since the Protestant Reformation, which is largely responsible for why it is a popular subject today. The dispute was between the Roman Catholics and Protestants. The Roman Catholics believed in the books of the Old Testament found exclusively in the traditional Greek Septuagint (called “Deuterocanon” by Catholics), whereas the Protestants (epitomized in the opinions of Martin Luther) believed the newer Hebrew Masoretic Text (which excluded those books called “Apocrypha” by Protestants) was more authoritative.
People make many assumptions when talking about the origins of “the canon.” Many Protestants point to the paschal encyclical of St. Athanasius (AD 367) as being proof that the New Testament canon was a settled issue in his day, simply because his letter includes a list of the same twenty-seven books of the New Testament seen in Bibles today. However, such data can be misleading. Dr. Eugenia Constantinou writes,
Athanasius’s list did not conclude discussion on the canon, not even for the Church of Alexandria, and indeed his canon was only one opinion among many. Far from settling the matter, the canon debate continued long after he had issued his encyclical. 
The canon was not discussed at the Council of Nicaea because they were primarily trying to stop Arianism from continuing to spread within the Church, and the canon of scripture simply was not a divisive issue. In the East, there was no perceived need to establish a concrete canon to be universally accepted by all Christians. However, because of how highly the West valued the opinions of Augustine and the Latin Vulgate, the West had developed their own unofficial closed canon by the fifth centuries. Another reason to reject the notion of a universally accepted canon is the fact that many of the Church Fathers had different canons. John Chrysostom’s canon had twenty-two books, and Gregory the Theologian’s canon had twenty-six books. One cannot prescribe a universal closed canon if the Church authorities do not even agree with one another. The Book of Revelation alone would have completely prevented agreement over the canon at the time of the 4th and 5th century. The historical data suggests that scripture was always a matter of local agreements across differing canons as defined region by region; not a universal consensus with regards to one canon used by all churches.
During the early stages of the Church, the heresy of Montanism was highly influential. The overemphasis on ecstatic spiritual spontaneity and chiliastic eschatology persuaded the apostasy of even Tertullian. Anti-Montanists such as Gaius started to reject all Johannine writings as a reaction against the Montanist emphasis on a literal understanding of the Book of Revelation. The anti-Montanists argued that “discrediting the apostolic authorship of the entire Johannine corpus was the most convenient and expedient means to undermine Montanist claims.”  However, even though the intention to reject heresy and preserve orthodoxy is a good one, it could be argued that the means they chose to execute that intention was disastrous. Despite the fact that people like Gaius were largely unsuccessful in drawing Orthodox Christianity away from all writings authored by John, the Book of Revelation became increasingly misunderstood and interpreted literally, which eventually caused the book to stop being commonly used in the East. It is not difficult to imagine how an extreme heresy and an extreme reaction to that heresy caused many Christians to throw up their hands and avoid eschatological/apocalyptic literature altogether.
Even though the Protestant New Testament is the same as the one St. Athanasius records, what many people seem to overlook is the fact that Athanasius has a different Old Testament. For example, Baruch and the Epistle of Jeremiah are listed as canonized books, but Esther was not.  Athanasius grouped together the Wisdom of Solomon, Sirach, Esther, Judith, Tobit, the Didache, and the Shepherd of Hermas to be read by catechumen for them to be instructed in piety, but they have not been canonized. Some may be surprised to learn that Athanasius did not call any of these books apocryphal. Rather, he specifically defined apocrypha as exclusively being the gnostic pseudepigraphal texts (such as the “Gospel of Thomas”) that the heretics falsely claimed had apostolic authorship.
Prior to Athanasius, Origen reveals his own New Testament canon in his commentary on the Book of Joshua, as recorded by Rufinus of Aquileia. Origen is also considered to be among the first Christians to compose a canon. He writes,
Matthew first sounded the priestly trumpet in his Gospel; Mark also; Luke and John each played their own priestly trumpets. Even Peter cries out with trumpets in two of his epistles; also James and Jude. In addition, John also sounds the trumpet through his epistles, and Luke, as he describes the Acts of the Apostles. And now that last one comes, the one who said, ‘I think God displays us apostles last,’ and in fourteen of his epistles, thundering with trumpets, he casts down the walls of Jericho and all the devices of idolatry and dogmas of philosophers, all the way to the foundations. 
The Apostolic writings were shared among Churches, but the term “scriptures” were at first generally reserved exclusively for the Old Testament. Despite not being called scripture, these writings, including the writings of their disciples Clement of Rome, Polycarp of Smyrna, and Ignatius of Antioch (along with the non-canonical writings Athanasius mentions), were also considered to be inspired and authoritative. New Testament writings were not seen so much as additions to the Old Testament, but rather a divinelyauthoritative, practical, and instructive interpretation of the Old Testament scriptures. Thus, in a period of violent theological division among the Jewish people, the ‘Christocentric hermeneutic’ of the Old Testament scriptures (among those who believed the interpretation) came to be just as important as the Old Testament itself, especially in the liturgical life of the Church.
There were actual apocryphal texts that sought legitimacy by claiming to be authored by the Apostles. However, this problem was still not solved by a universal declaration at an Ecumenical Council. There were plenty of gnostic heretics who misinterpreted the scriptures, but the scriptures are not self-interpretative. Therefore, differences of hermeneutics alone would not have warranted a formal discussion about a universal canon, because Orthodox and Heterodox alike interpret the same Old Testament. Early Christendom always seemed to solve the apocrypha problem at a local level. St. Irenaeus, bishop of Lyons, is one such example. Constantinou writes how Irenaeus argued for apostolic authorship as “the basis for placing certain Christian writings nearly on par with the Jewish Scriptures.”  Irenaeus is also known for supporting four gospels, instead of accepting a fifth “Gospel of Truth” by Valentinus. Bishops like Irenaeus were also influential in detailing what constitutes a canonical text. The two main tests seem to be whether or not it came from the time of the Apostles, and whether or not it agreed with the Church’s oral tradition handed down from the Apostles.
Many people also cite the Council of Trullo (AD 692) when they talk about the formation of the canon. However, the Council of Trullo merely ratified the conflicting canons of previous local councils. Constantinou writes,
Trullo’s complete and indiscriminate ratification preserved the status quo, leaving the matter open to individual persons, local bishops, and regional preferences. 
As far as modern Christianity is concerned, the Roman Catholic Church declared its official canon at the Council of Trent (1546) as a response to Protestant dissent, and remains to be the only church with an official canon for all its people.
Orthodox Christians do not have an official canon, but there is unity nonetheless in practice and consensus with an unofficial canon.
Protestants are similar to the Orthodox in that they do not have an official canon, but it is largely because Protestants do not have an official and unifying church authority, tradition, teaching, or practice, and thus the subject of the canon is left entirely to each individual denomination [For example, many Anglicans accept the Deuterocanon (some even the Epistles of Clement and Ignatius), and there are Fundamentalist congregations which reject the Book of Hebrews].
The canon of scripture was never universally closed or explicitly declared at any Ecumenical Council. It was briefly discussed by various bishops in writings and local councils, but it was never officially closed and there was never universal consensus. Heresy was responsible for inciting people to reject certain books, however, it never went beyond the local level, and ancient Christendom seemed to be okay with that.
 Eugenia S. Constantinou, Guiding to a Blessed End: Andrew of Caesarea and His Apocalypse Commentary in the Ancient Church. (Washington, D.C.: Catholic University of America Press, 2013), 16.
 Ibid., p. 16-17.
 Syriac Peshitta excluded 2 Peter, 2 John, 3 John, Jude, and Revelation.
 Ibid., p. 33-34. Gregory’s canon excluded Revelation.
 Ibid., p. 22-23.
 Ibid., p. 23.
 Ibid., p. 24.
 David Brakke, “A New Fragment of Athanasius’ Thirty-Ninth Festal Letter: Heresy, Apocrypha, and the Canon*.” (Harvard Theological Review, 2010), 60-61.
 Ibid., p. 61.
 Ibid., p. 61-62.
 Eugenia S. Constantinou, Guiding to a Blessed End: Andrew of Caesarea and His Apocalypse Commentary in the Ancient Church. (Washington, D.C.: Catholic University of America Press, 2013), 25.
 Edmon L. Gallagher, “Origen Via Rufinus on the New Testament Canon.” (New Testament Studies, 2016), 462.
 Lee M. McDonald, The Biblical Canon: Its Origin, Transmission, and Authority. (Peabody, Mass: Hendrickson Publishers, 2007), 22.
 Ibid., 23-24.
 Now known as the “New Testament.”
 David Brakke, “A New Fragment of Athanasius’ Thirty-Ninth Festal Letter: Heresy, Apocrypha, and the Canon*.” (Harvard Theological Review, 2010), 61.
 Eugenia S. Constantinou, Guiding to a Blessed End: Andrew of Caesarea and His Apocalypse Commentary in the Ancient Church. (Washington, D.C.: Catholic University of America Press, 2013), 19.
 Michael A. Smith. From Christ to Constantine. (London: Inter-Varsity Press, 1971), 63.
 Ibid., p. 65.
 Eugenia S. Constantinou, Guiding to a Blessed End: Andrew of Caesarea and His Apocalypse Commentary in the Ancient Church. (Washington, D.C.: Catholic University of America Press, 2013), p. 36-37.
 Ibid., p. 37.