A thing is said to be impossible in respect of a power in two ways. First, on account of an inherent defect in the power, in that the effect is beyond its reach, as when a natural agent cannot transform a certain matter. Secondly, when the impossibility arises from without, as in the case of a power that is hindered or tied. Accordingly there are three ways in which it is said to be impossible for a thing to be done. First, by reason of a defect in the active power, whether in transforming matter, or in any other way. Secondly, by reason of a resistant or an obstacle. Thirdly, because that which is said to be impossible cannot be the term of an action. Those things, then, which are impossible to nature in the first or second way are possible to God: because, since his power is infinite, it is subject to no defect, nor is there any matter that he cannot transform at will, since his power is irresistible. On the other hand those things which involve the third kind of impossibility God cannot do, since he is supreme act and sovereign being: wherefore his action cannot terminate otherwise than principally in being, and secondarily in nonbeing. Consequently he cannot make yes and no to be true at the same time, nor any of those things which involve such an impossibility. Nor is he said to be unable to do these things through lack of power, but through lack of possibility, such things being intrinsically impossible.
De Potentia, q. 1 art. 3 corp.