(2Jo 1:9 ESV) Everyone who goes on ahead and does not abide in the teaching of Christ, does not have God. Whoever abides in the teaching has both the Father and the Son.
A couple of points to begin:
First, John is not contradicting what he taught in his Gospel or in 1 John. Everyone with faith in/faithfulness to/trust in Jesus is saved. Clearly, “the teaching of Christ” must be the gospel, that is, what one must believe to have faith. Any other interpretation would cause John to contradict himself in countless ways.
Second, the Greek scholars debate whether “of Christ” is objective (what Jesus taught) or subjective (the teaching about Jesus). The end result is the same either way. In John’s Gospel, the focus of Jesus’ teaching is his own messiahship and mission. John is not speaking of a body of doctrine and denominational boundary markers. His focus in on Jesus himself.
So let’s look at the context.
(2Jo 1:1-3 ESV) The elder to the elect lady and her children, whom I love in truth, and not only I, but also all who know the truth, 2 because of the truth that abides in us and will be with us forever: 3 Grace, mercy, and peace will be with us, from God the Father and from Jesus Christ the Father’s Son, in truth and love.
In the NT, “truth” is almost always used to mean “gospel.” I did a brief series several years ago covering every relevant NT passage. Of particular interest would be —
(Joh 14:6 ESV) 6 Jesus said to him, “I am the way, and the truth, and the life. No one comes to the Father except through me.”
(1Jo 2:21-23 ESV) 21 I write to you, not because you do not know the truth, but because you know it, and because no lie is of the truth. 22 Who is the liar but he who denies that Jesus is the Christ? This is the antichrist, he who denies the Father and the Son. 23 No one who denies the Son has the Father. Whoever confesses the Son has the Father also.
There is an excellent essay on this point in Leon Morris’ New International Commentary on John.
Now, if we take “truth” to mean something like “Jesus is the Messiah, the Son of God, who came in the flesh and who was crucified for our sins and resurrected by the Father,” then John’s first few verses in 1 John make perfect sense and fit his overall teaching in his Gospel and 1 John.
In particular, we know from 1 John, that the community John was writing to was dealing with certain “antichrists” who denied the incarnation. Hence,
(1Jo 4:1-6 ESV) Beloved, do not believe every spirit, but test the spirits to see whether they are from God, for many false prophets have gone out into the world. 2 By this you know the Spirit of God: every spirit that confesses that Jesus Christ has come in the flesh is from God, 3 and every spirit that does not confess Jesus is not from God. This is the spirit of the antichrist, which you heard was coming and now is in the world already. 4 Little children, you are from God and have overcome them, for he who is in you is greater than he who is in the world. 5 They are from the world; therefore they speak from the world, and the world listens to them. 6 We are from God. Whoever knows God listens to us; whoever is not from God does not listen to us. By this we know the Spirit of truth and the spirit of error.
John distinguishes “truth” from “error” based on whether someone confesses “that Jesus Christ has come in the flesh.”
Continuing in 2 John —
(2Jo 1:7-8 ESV) 7 For many deceivers have gone out into the world, those who do not confess the coming of Jesus Christ in the flesh. Such a one is the deceiver and the antichrist. 8 Watch yourselves, so that you may not lose what we have worked for, but may win a full reward.
What is the issue John is confronting in 2 John? Plainly, once again, whether Jesus, the Messiah, came in the flesh. Those who deny this, he says, are damned.
(2Jo 1:9-11 ESV) 9 Everyone who goes on ahead and does not abide in the teaching of Christ, does not have God. Whoever abides in the teaching has both the Father and the Son. 10 If anyone comes to you and does not bring this teaching, do not receive him into your house or give him any greeting, 11 for whoever greets him takes part in his wicked works.
“The teaching of Christ” and “this teaching” is the same thing. Plainly. Anyone who denies Jesus should not be welcomed into your house or greeted. This is plainly not just any error or sin. He’s not referring to those Christians who are less than perfect or have any doctrinal error of any kind. Plainly, he’s talking about an error at the core of Christianity — whether Jesus is the Messiah (Christ) come in the flesh.
He is not saying that all disagreements and all errors require us to deny fellowship. Not at all. He’s saying that all with faith in Jesus are saved; no one else is.