It seems reasonable to define God as a conscious being that is the first cause of reality. Being the first cause, God is uncaused. Suppose that God possibly exists. In that case there is a possible world w in which God exists. According to Leibniz's weak principle of sufficient reason (wPSR) there must be a sufficient reason for every thing that exists.* So, following this principle, there must be a reason in w for Gods existence. God exists in w either by virtue of its own nature, or due to an external cause. Since God is uncaused in w it follows that God exists by virtue of its own nature in w. That is to say, God exists necessarily in w. But then, assuming S5 modal logic, it follows that God exists in all possible worlds. So God exists necessarily. Therefore, given wPSR and S5, Gods possible existence entails Gods necessary existence.
(*) Note that this is indeed a weak version of Leibniz' principle, since it is not claimed that there is a sufficient reason for each fact or state of affairs. It is "merely" claimed that every existing thing (i.e., object or entity) has a reason for its existence.