Baptism without repentance and faith is not sufficient for salvation, so John condemns the leaders’ hypocrisy, both to seek their repentance, and to warn the people against their self-righteousness.
No, baptism as such, in the absence of true repentance, does not save one from judgment. John calling out the Pharisees and Sadducees who came to his baptism is therefore not loveless, but an attempt to show these people their own sins as well as the means of escaping the judgment of God. At the same time the people also need to be warned against the heresies of these two groups. John’s intention here was not to say that their coming to his baptism was in vain in and of itself, but rather to denounce their entire theological system, thereby highlighting that even if they were to be baptized it would not save them. In other words, baptism would be of no benefit to them if they pursued it with a sinful motivation.1
7 But when he saw many of the Pharisees and Sadducees coming to his baptism, he said to them, “You brood of vipers! Who warned you to flee from the wrath to come?