It's in John where Jesus is said to have existed alongside the Father from the beginning and have created all things together with him. I think it's in Matthew that Jesus is quoted telling his followers to make disciples in the name of the Father, the Son and the Holy Spirit. That's probably where the formula for the Trinity came from. Luke's gospel and Acts also talk about the Holy Spirit quite a bit. The concept of the Trinity is the Church's way to try to reconcile all these passages with the Jewish belief in Monotheism.