In Elections Are Not Democracy, Fareed Zakaria lays out the three conditions for becoming a liberal democracy, rather than an illiberal democracy:
First, you need to avoid major ethnic or religious strife. In almost any ‘divided’ society, elections can exacerbate group tensions unless there is a strong effort to make a deal between the groups, getting all to buy into the new order.
[...]
Second, create a non-oil-based economy and government. When a government has easy access to money, it doesn’t need to create a real economy.
[...]
The rule of law is the final, crucial condition. Without it, little else can work.