Through the Goblet of Fire (hence the name of the book) which was a magical cup that without bias choose the best student entered in each school. This way, it would be impartial. However, Crouch Jr. confunding the cup to get Harry's name made it a bit more complicated. Apparently, it has a "binding magical contract" and you have to compete if you're chosen.
The cup was confunded by putting the name of a different school with Harry's name.