In a sense, the rise of agriculture in river valleys was because flooding would naturally fertilize the fields with mineral rich silt, so it pretty much goes back as far as agriculture itself.
In the sense of humans deliberately spreading something to fertilize crops, the earliest I'm aware of is when agriculture was spreading through Europe about 8000 years ago
Synthetic fertilizer is a product of the industrial revolution with Lawes patenting a processed manure product in 1842.