Market failure occurs when the free market does not allocate resources efficiently to maximize societal welfare. It happens when the market output level does not coincide with where marginal social costs equal marginal social benefits. This means the market overproduces or underproduces a product compared to the efficient level where welfare is maximized. Market failure definitionally refers to situations where the allocation of resources by the market mechanism is inefficient.