Chapter X of Book IV of An Essay Concerning Human Understanding by John Locke.
Of our Knowledge of the Existence of a God
1. We are capable of knowing certainly that there is a God. Though God has given us no innate ideas of himself; though he has stamped no original characters on our minds, wherein we may read his being; yet having furnished us with those faculties our minds are endowed with, he hath not left himself without witness: since we have sense, perception, and reason, and cannot want a clear proof of him, as long as we carry ourselves about us. Nor can we justly complain of our ignorance in this great point; since he has so plentifully provided us with the means to discover and know him; so far as is necessary to the end of our being, and the great concernment of our happiness. But, though this be the most obvious truth that reason discovers, and though its evidence be (if I mistake not) equal to mathematical certainty: yet it requires thought and attention; and the mind must apply itself to a regular deduction of it from some part of our intuitive knowledge, or else we shall be as uncertain and ignorant of this as of other propositions, which are in themselves capable of clear demonstration. To show, therefore, that we are capable of knowing, i.e. being certain that there is a God, and how we may come by this certainty, I think we need go no further than ourselves, and that undoubted knowledge we have of our own existence.
2. For man knows that he himself exists. I think it is beyond question, that man has a clear idea of his own being; he knows certainly he exists, and that he is something. He that can doubt whether he be anything or no, I speak not to; no more than I would argue with pure nothing, or endeavour to convince nonentity that it were something. If any one pretends to be so sceptical as to deny his own existence, (for really to doubt of it is manifestly impossible,) let him for me enjoy his beloved happiness of being nothing, until hunger or some other pain convince him of the contrary. This, then, I think I may take for a truth, which every one's certain knowledge assures him of, beyond the liberty of doubting, viz. that he is something that actually exists.
3. He knows also that nothing cannot produce a being; therefore something must have existed from eternity. In the next place, man knows, by an intuitive certainty, that bare nothing can no more produce any real being, than it can be equal to two right angles. If a man knows not that nonentity, or the absence of all being, cannot be equal to two right angles, it is impossible he should know any demonstration in Euclid. If, therefore, we know there is some real being, and that nonentity cannot produce any real being, it is an evident demonstration, that from eternity there has been something; since what was not from eternity had a beginning; and what had a beginning must be produced by something else.