Essentially, Alfred is remembered as a great king for his efforts to repel the Viking invasions of Wessex. At first alongside King Ethelred, and then on his own, Alfred led Saxon armies against repeated Viking invasions. His record against them on the battlefield was mixed, and more than once Alfred was forced to pay tribute to keep the Vikings at bay. After one particularly severe defeat in 878, Alfred fled into the wilderness in Athelney, from which he led a series of hit-and-run operations against the Vikings, who had occupied much of Wessex. According to the Anglo-Saxon Chronicle for 878:
This year about mid-winter, after twelfth-night, the
Danish army stole out to Chippenham, and rode over the land oft the West-Saxons; where they settled, and drove many of the people over sea; and of the rest the greatestpart they rode down, and subdued to their will; ALL BUT ALFRED THE KING. He, with a little band, uneasily sought the woods and fastnesses of the moors.
After returning to gain his first decisive victory later that year, Alfred negotiated a peace with the invaders, who left to settle in East Anglia and elsewhere. When a new wave of invaders came in 892, he forged an alliance with Mercia that enabled him to drive away the Vikings yet again. So essentially, he just drove them out of Wessex, and then Mercia.