The girl is at court with her beautiful social butterfly sister. The beautiful sister messes up but the Queen blames the influence of the other sister because she doesn't want to lose the beautiful sister. The Queen banishes the girl to a remote castle where she is allowed no contact with anyone outside the castle, especially not her sister. She arrives after a little girl has been stolen by a race of creatures that lives underground. The little girl's brother (or cousin) is exchanged for the girl to be part of some ceremony that is necessary for the underground race's survival. The girl from court gets caught watching the exchange and is taken underground. She ends up foiling all their plans and the race is basically destroyed by underground flooding. I remember a line about "un-horsing the rider" where she talks the drugged brother going to his doom into getting off his horse, which breaks some sort of spell.