There is a link between the rule of law and democracy, similar to but without the same tenacity as the link between human rights and democracy. A democracy is by definition a system that respects the rule of law. The democratic election procedures and the human rights necessary for the functioning of democracy are written into enforceable laws that are the sovereign rulers and that govern everybody in the same and equal way.
A democracy respects human rights and therefore, also respects the rule of law, because the rule of law is a part of human rights (some human rights specifically install the rule of law).
However, a state that respects the rule of law does not have to be a democracy. The laws that rule do not have to be democratic laws, do not have to be framed by the people, and do not have to conform to human rights. In order to have a rule of law, it is sufficient that the law rules and that there is a separation of powers, which guarantees and enforces respect for the law. The content and the origin of the laws are irrelevant for the rule of law, but not for democracy and human rights.
A state that respects the rule of law does not have to be a democracy, but the rule of law has the best chances of survival in a democracy. When the people frame the laws, it is more likely that the people will respect the laws, and the laws rule when they are respected. You do not make a law if you plan to break it afterwards. There is no comparison between a law that you impose on yourself and a law that someone else imposes on you. Furthermore, the rules regarding the correct way of handling a court procedure, as they are expressed in certain human rights, make it more likely that the law is enforced in a just and acceptable manner, which also contributes to the rule of law. A system that respects human rights – e.g. a democracy – is therefore more likely to contribute to the rule of law.
A democracy without the rule of law is a farce. Elections alone are not enough. Elections can be manipulated and can be used as a ploy of a leader seeking legitimacy. They can be falsified or they can be held and neglected afterwards. Elections can only be fair within the rule of law. Only the rule of law can enforce respect for election rules and election results. Furthermore, without the rule of law, human rights are not enforceable, and without human rights, there is no proper democracy.
Of course, a democracy requires more than legal protection of the rules and rights which are necessary for the creation and the expression of the will of the people. Once power is granted on the basis of the expression of the will of the people, it is the job of those in power to implement the will of the people. The way in which this will can be implemented, in other words the exercise of power, is also regulated by laws, otherwise, there would be no rule of law. It is not because power comes from the people that this power is always beneficial. It needs to be limited by the principles of the rule of law and by human rights, just as any other kind of power.
The rule of law requires the separation of powers. Courts must be able to protect the laws against bad behavior by other parts of the state. They must also protect the law against the law. Legislation may be designed to violate other laws, for example the fundamental human rights enshrined in the constitution. The courts must be able to stop such legislation. When power is divided, one power can correct the other.