When a theory is confronted with a problem such as a paradox, an empirical anomaly, or a vicious regress, one may change part of the theory to solve that problem. Sometimes the proposed solution is considered ad hoc. This paper gives a new definition of ‘ad hoc solution’ as used in both philosophy and science. I argue that a solution is ad hoc if it fails to live up to the explanatory requirements of a theory because the solution is not backed by an explanation or because it does not diagnose the problem. Ad hoc solutions are thus magical: they solve a problem without providing insight. This definition helps to explain both why ad hoc solutions are bad and why there may be disagreement about cases.