In 1970, the state of Oregon sued U.S. Attorney General John Mitchell in response to a federal law that made states reduce their voting age to 18. Oregon's voting age was 21, and the state felt it was unconstitutional to be forced to lower it. The Court's 5-4 decision ruled in Oregon's favor, giving the state (and therefore other states) the right to set their own election age laws.
This created a somewhat confusing legal patchwork, since the federal government could still mandate the age limits for federal elections, which it set at 18. In states that used an age limit of 21, separate voter registries for state and federal elections were required. In cases where both state and federal elections occurred at the same time, some voters would have been able to vote on only some portions of the ballot.
The confusion was sorted out by the 26th Amendment, adopted in 1971. The amendment set the national voting age to 18 for all elections, and was passed by 38 states in a matter of months - the fastest constitutional amendment ever adopted. It's interesting to note that the amendment forbids states (or anyone else) from taking away voting rights from anyone 18 or older. It doesn't prevent states from granting voting rights to anyone below age 18.