The short answer
Hunger is chiefly generated by networks in the brain, particularly within the hypothalamus. These networks combine information about the body's immediate supply of nutrients, its longer term energy reserves, the contents of the digestive tract, the time of day and the availability or attractiveness of food. The resulting sensation encourages us to seek and eat food.
The body's signals
One important short term signal is ghrelin, a hormone produced mainly by the stomach. Its level commonly rises before meals and during fasting, then falls after eating. Ghrelin can stimulate brain pathways that increase appetite, but it is one contributor rather than a single hunger switch.
The brain also receives information about circulating nutrients and hormones. Insulin helps signal the body's nutritional state. Leptin, released mainly by fat tissue, provides a broader indication of stored energy. When leptin signalling falls, as it does when fat stores are reduced, the brain tends to increase hunger and conserve energy. In common obesity, leptin can be abundant while the brain responds to it less effectively, so leptin is not merely a simple fullness gauge.
Nerves, including pathways involving the vagus nerve, report stretch and chemical conditions in the stomach and intestines. After food arrives, gut hormones and nutrient signals generally support satiation, the process that brings a meal to an end, and satiety, the period of reduced desire to eat afterwards.
Why an empty stomach is not the whole explanation
Stomach contractions may contribute to familiar hunger pangs, but an empty stomach is neither necessary nor sufficient to explain hunger. The hypothalamus integrates bodily signals with reward and motivation systems elsewhere in the brain. Smell, sight, memory, habit, stress and the expectation of a customary mealtime can therefore make food appealing even when the body's immediate energy shortage is slight.
The body's circadian clock also helps organise appetite across the day. This is why hunger may appear at an expected hour and sometimes recede if a meal is delayed. In practical terms, hunger is best understood as a brain generated judgement based on many imperfect signals, not as a fuel warning light wired directly to the stomach.