The great English theologian John Owen (1616-1683) wrote:
Men may be really saved by that grace which doctrinally they do deny;
and they may be justified by the imputation of that righteousness which in opinion they deny to be imputed.
—The Doctrine of Justification by Faith Alone, in Owen’s Works 5:163-64.
In some ways Owen’s position is a dangerous one to hold—given the strong connection in Scripture between sound doctrine and assurance—but it’s nevertheless an important principle. Note that Owen doesn’t say that they necessarily are saved but that they may be saved.
I also agree with the qualifier John Piper adds: “The clearer the knowledge of the truth and the more deep the denial, the less assurance one can have that the God of truth will save him. Owen’s words are not meant to make us cavalier about the content of the gospel, but to hold out hope that men’s hearts are often better than their heads” (The Future of Justification, p. 25 n. 30).
Jonathan Edwards (1703-1758) offers a similar statement to Owen’s but goes into greater detail with various options regarding the denial—emphasizing how dangerous false teaching is but also hoping that such a person may be teachable when confronted with his error:
How far a wonderful and mysterious agency of God’s Spirit may so influence some men’s hearts, that their practice in this regard may be contrary to their own principles, so that they shall not trust in their own righteousness, though they profess that men are justified by their own righteousness—
or how far they may believe the doctrine of justification by men’s own righteousness in general, and yet not believe it in a particular application of it to themselves—
or how far that error which they may have been led into by education, or cunning sophistry of others, may yet be indeed contrary to the prevailing disposition of their hearts, and contrary to their practice—
or how far some may seem to maintain a doctrine contrary to this gospel-doctrine of justification, that really do not, but only express themselves differently from others;
or seem to oppose it through their misunderstanding of our expressions, or we of theirs, when indeed our real sentiments are the same in the main—
or may seem to differ more than they do, by using terms that are without a precisely fixed and determinate meaning—
or to be wide in their sentiments from this doctrine, for want of a distinct understanding of it;
whose hearts, at the same time, entirely agree with it, and if once it was clearly explained to their understandings, would immediately close with it, and embrace it:—
how far these things may be, I will not determine; but am fully persuaded that great allowances are to be made on these and such like accounts, in innumerable instances; though it is manifest, from what has been said, that the teaching and propagating [of] contrary doctrines and schemes, is of a pernicious and fatal tendency. (“Justification by Faith Alone,” in Yale’s Works of Jonathan Edwards 19:242.)