Both Media and Persia were ancient kingdoms in what is now Iran. The Medes emerged as a unified kingdom during the period of the Neo-Assyrian Empire. They formed an alliance with the Babylonians to capture Nineveh (612 BC) resulting in the collaspe of the Neo-Assyrian Empire. The Median Empire had dominance over the kingdom of Persia until Cyrus, king of Persia, rebelled against Asytages, king of Media, and claimed the throne of Media. The empire under Cyrus is sometimes known as the Medo-Persian Empire or as Achaemenid Persian Empire.
Daniel 8:1-4 represents Media and Persia as the two horns of a ram. One horn came up second and grew higher than the first horn. This matches the history of Media and Persia, where Media originally was the dominate kingdom but ultimately Persia became the greatest empire.