AbstractMany philosophers are baffled by necessity. Humeans, in particular, are deeply disturbed by the idea of necessary laws of nature. In this paper I offer a systematic yet down to earth explanation of necessity and laws in terms of invariance. The type of invariance I employ for this purpose generalizes an invariance used in meta-logic. The main idea is that properties and relations in general have certain degrees of invariance, and some properties/relations have a stronger degree of invariance than others. The degrees of invariance of highly-invariant properties are associated with high degrees of necessity of laws governing/describing these properties, and this explains the necessity of such laws both in logic and in science. This non-mysterious explanation has rich ramifications for both fields, including the formality of logic and mathematics, the apparent conflict between the contingency of science and the necessity of its laws, the difference between logical-mathematical, physical, and biological laws/principles, the abstract character of laws, the applicability of logic and mathematics to science, scientific realism, and logical-mathematical realism.