The balance among different powers is the solution.

The shari‘a has the capacity to function as a tool for the
fair administration of justice. But like any other legal system,
it cannot do so if it is not embedded in a constitutional order
in which the dictates of the law are enforced by institutions
with the incentive to act justly and the real-world powers to see
that their rulings are executed in practice. The shari‘a is no
magic solution to the problem of the rule of law.