In a book so mind-blowingly insightful that I had to stop marking because the whole page was turning red, I read the most concise, precise, comprehensive, and accurate definition for speculation: "buying commodities for the capital gain from anticipated increases in their prices rather than for their use."
As an example, buying oil or wheat to have fuel or grain is not speculation, but buying them to trade them to someone else after their value rises is. Note that it is only speculation if the gain on the commodity is a capital one rather than an operating (or ordinary income) one. In other words, if you are a distributor, retailer, broker, or trader of oil or wheat, you are not speculating. The precise difference between a capital gain and an ordinary gain on a commodity can be fuzzy in some cases, but in general is quite clear.
Once speculation is defined that way, the next step is to consider the special case where the commodity is a stock. Stock is definitely a commodity: one share of a given class of stock in a given company is completely exchangeable for another share of the same class of stock in the same company. Most other securities are commodities as well.
In the case of a security, a capital gain is the result of income from selling the security at a higher price than paid for it. Operating income is the dividends or payments from the security during the period that it is held.
This definition might miss a few cases in its simplicity, such as growth stocks that don't pay dividends, but it's pretty much spot on.
The books is Manias, Panics, and Crashes by Charles Kindleberger. Kindleberger was a professor of economics at MIT for 30 years, and his book is widely cited by other books on market cycles such as Bull! by Maggie Mahar, which is where I read about it.