Just before the hangover. Okay, actually beer likely dates back to the dawn of cereal agriculture, loosely pinpointed at 10,000 B.C.E. in ancient Mesopotamia, the region of southwest Asia currently occupied by Iraq.
The alcoholic inception is reckoned to have occurred when some early farmer sampled water in which bread had been sitting (and fermenting) for a day or two. The first brews would have been concoctions of crushed or malted grain steeped and heated slowly in water, and then baked and submerged again. The oldest recorded evidence of brewing is in the epic of Gilgamesh (c. 2500 B.C.E. or 3500 B.C.E by differing accounts), related by the Sumerians on clay tablets. By 2000 B.C.E. the Sumerians had concocted recipes for eight different beers made from barley and eight from wheat. These syrupy, nutritious beers ranged from "strong" to "red brown" to "good dark" — and they soon caught on elsewhere.
The ancient Egyptians loved their suds, preferring beer to water (which was often contaminated). The Egyptians in turn spread beer to the Greeks, who, as you might have guessed, preferred wine as their Dionysian drink.