Nilson was born in Skönberga parish in Östergötland, Sweden. His father, Nikolaus, was a farmer. The family moved to Gotland when Lars Fredrik was young. After graduating from school, Lars Fredrik enrolled at Uppsala University, and there he studied the natural sciences. His talent for chemistry drew attention from chemistry professor Lars Svanberg, who was a former student of Jöns Jakob Berzelius.
In 1874 Nilson became associate professor of chemistry, and from then on he could devote more time to research. While working on rare earths, in 1879 he discovered scandium. During this time he also studied the gas density of metals which made it possible to determine the valence of various metals.
In 1882 he became director of the chemistry research department of the Royal Swedish Academy of Agriculture and Forestry. His research partially took a new direction from then on. He conducted studies on cow milk and various fodder plants.
Nilson was a member of several academies and got several awards, including the Order of the Polar Star.