I few weeks ago I discussed my views on the Gospel of Judas and how the final cannon was decided. I found an excellent audio clip from a lecture on the Canonization of the New Testament by Bart Ehrman (a New Testament scholar) that may help clear up exactly how this happened.
From the Straight Dope, “The first officially sanctioned canon of the New Testament was attempted by Irenaeus of Lyon. Irenaeus saw the effect Gnosticism was having on Christianity and feared that the church was splintering into factions. Formalizing doctrinal authority seemed to be the answer. He felt there were two sources of authority: Scripture and the apostles. A work could be accepted as canonical if the early church fathers used it. He never really compiled a list of books, but he did establish the basis for subsequent determinations of orthodoxy.” You can also read a great article on this here.