Descartes gives two primary arguments for the existence of God. The first argument that Descartes gives of God's existence is commonly referred to as the "Ontological Argument". The Ontological Argument goes as follows: (1) Our idea of God is of a perfect being. (2) It is more perfect to exist than not to exist. (3) Therefore, God must exist.
The second argument that Descartes gives for this conclusion is far more complex. This argument rests on the distinction between two sorts of reality. Formal reality is the reality that anything has in virtue of existing. Formal reality comes in three grades: infinite, finite, and modes. God is the only existing thing with infinite formal reality. Substances all have finite formal reality. Finally, modes have modal formal reality. An idea, insofar as it is considered as an occurent piece of thought, has modal formal reality (since any particular thought is just a mode of mind).
Ideas, however, also have another kind of reality, unique to them. When considered in their relation to the objects they represent, ideas can be said to have objective reality. There are three grades of objective reality, precisely mirroring the three grades of formal reality. The amount of objective reality contained in an idea is determined solely on the basis of the amount of formal reality contained in the object represented by an idea. An idea of red has modal objective reality, because red has modal objective reality. An idea of a stone has finite objective reality, because stones have finite formal reality. Finally, the idea of God had infinite objective reality, because God has infinite formal reality.
It is the idea of God that is crucial to the causal argument. Descartes begins the argument by making the controversial claim that we all have an idea of God as an infinite being. (He believes that we cannot fail to have this idea because it is innate.) Because this idea is of an infinite being, it must have infinite objective reality. Next Descartes appeals to a logical principle: something cannot come from nothing. Reasoning from this principle he arrives at two other causal principles: (1) there must be as much formal reality in a cause as in an effect, and so, (2) there must be as much formal reality in a cause of an idea as there is objective reality in an idea. Since we have an idea with infinite objective reality (namely, the idea of God), Descartes is able to conclude that there is a being with infinite formal reality who caused this idea. In other words, God exists.