Our text is one that is highly controversial in our time, as it clearly shows that some who claim to be Christians are not worthy of fellowship and are to be rejected by the righteous. Such intolerance is not acceptable to many, but is required of us by God.
What differentiates between those who have God (are in fellowship with Him) and those who do not have God? Whether or not they abide in the doctrine of Christ. The term here could be literally rendered the “Messiah’s teaching.” (Very similar to the “apostle’s doctrine” in Acts 2:42). It includes the various doctrines concerning the person and work of Christ, but is not limited to those. Rather, it includes all that Christ taught. Both the teaching which He personally delivered to His disciples, and that promised by Him and delivered by the Holy Spirit (cf. John 16:13).
The Christian is not to associate with those who do not abide (stay, or remain) in the Messiah’s teaching. Unlike association with the world (cf. 1 Corinthians 5:9-13), to associate with false teachers among us is tantamount to fellowship. John says when we eat with them we share (jointly participate) in their evil deeds. No matter our desire for peace, this we must never do!