Leibniz had a strange belief that the essence of a substance ("monad" in his terms) contains everything that will ever happen to it. Every event that is going to occur during a substance's existence follows necessarily from its essence. Since people are substances, it's pretty obvious that this conflicts with freedom of the will, but Leibniz claims that the two doctrines can be reconciled. His concern was not the metaphysical determinism that modern compatibilists might seek to reconcile freedom with; instead Leibniz was attempting to absolve God of responsibility for the evils and sins committed by individual agents. But there are still a couple of interesting elements in Leibniz's account of freedom that make it potentially relevant to modern discussions.
The metaphysical background for Leibniz's doctrine of freedom is found in his Discourse on Metaphysics. There are contingent future events that are nonetheless certain because of God’s foreknowledge. But Leibniz also believes that the notion of a substance entails everything that will happen to it, so his explanation needs to go further than simply invoking a distinction between certainty and necessity. Leibniz distinguishes between absolute necessity (i.e., logical necessity) and accidental or ex hypothesi necessity (metaphysical necessity). The necessity associated with the unfolding of events in relation to the inner principle of the substance is the necessity of the latter type. Even though events occur with this metaphysical necessity their contraries do not imply contradiction, so they are not absolutely necessary. Not being absolutely necessary, they are still contingent (Discourse on Metaphysics, §13).
Leibniz examines freedom of the will in this context in his Theodicy. The will is exempt from constraint and from necessity (Theodicy, §34). This does not mean that there is nothing that prompts us to choose, just that no necessity prevents our choosing (§35). While it is the case that the truth of future contingents is certain (§36) this does not mean that they are necessary. Necessity should be narrowly construed as logical necessity (§37). Even God’s foreknowledge does not make the future necessary (§38).
Leibniz solves the problem of future contingencies in part by an appeal to the infinity of possible worlds; future contingencies are certain in particular possible worlds, one of which is the actual world, but are not necessary as a consequence of this, even if God has foreknowledge (§42). The will is inclined towards the course it adopts, but not necessitated (§43). Leibniz contrasts his restriction of necessity to logical necessity with the principle of determinate [i.e., sufficient] reason, which holds that there is a reason state of affairs obtains rather than another (§44). The will is prompted by a reason when it moves us to action (§45). Choices are not necessitated, however (§46), and so there is no need to resort to immediate divine determination in order to explain the sequence of events (§47).
Now, Leibniz believes that God foresaw all future contingents in all possible worlds and chose the most perfect world, which entails that God cannot change the world without reducing its perfection; any change one makes to the best possible world would only reduce its perfection. But this does not mean that things are as they are out of necessity (§53). The certainty of future contingents does not mean that God cannot miracles; miracles, too, are certain in the possible world that God has chosen to make actual (i.e., God foresaw in the best possible world that he would perform certain miracles) (§54).
Leibniz thinks his system is maximally favorable to freedom (§63) since everything that happens to a soul derives from the soul. Every state of a soul is dependent upon its prior state (§64). The soul contains the principle of all its actions and passions; the same is true of all other simple substances as well (§65).
Now obviously some of the concerns of Leibniz are outmoded, and his metaphysical system is bizarre and speculative, but I think there are some elements here that are still current in debates about free will.
First, Leibniz (like Locke and Sam Harris) believed that an action deriving in some relevant sense was sufficient for us to ascribe moral responsibility to an agent, even if it were not the case that the agent could have done otherwise in a strict sense. Leibniz holds, of course, that we could have done otherwise, as long as the "otherwise" isn't logically impossible. But that doesn't really speak to the core intuition about the ability to do otherwise. Once God chooses the possible universe in why I X, my not Xing would be a change in the world and would reduce its perfection. So there is a real sense in which everything that happens (including my choices) can't be otherwise if God is selecting the best possible world. But it might be the case that Leibniz has hit on something relevant when he claims that moral responsibility for an action is derived primarily from the fact that such an action is the outcome of some internal characteristic of ourselves (even if we don't buy his notion of "essences"), rather than from our metaphysical freedom to have done otherwise. If he's right about this (and I'll not go into that here), then Leibniz may have something to say to us today.
Second, Leibniz makes an important distinction between what we might call volition and choice. If we are to believe that we have some modicum of freedom, that has to be analyzed within the context of causes, whether we adhere to naturalism or not. For even in a hypothetical version of the world in which supernatural events take place we wouldn't want to assume that those events are arbitrary; i.e., that there are no causes. Even if we are able to locate and defend some version of the ability to do otherwise in a given action, that likely won't take place at the expense of thinking about our choices as being caused by our volition in a very relevant sense. Our appetites, desires, hopes, ends, etc. are, as Leibniz would say, "principles of sufficient reason" for us to choose to X instead of choosing to not X. This won't mean that we can't do otherwise, necessarily, but it will mean that a casual account of choosing will have to take note of the complex of internal states we call our volition in some sense leads to the choices we make.