Need output voltages of 0V or 5V based on analog range
A comparator will do this. Set the power supply to 5V, and connect the inverting input to 2.5V. The variable voltage goes to the non-inverting input. The output will be high if the non-inverting input is higher than the inverting, and low otherwise.  

The TLV7211 (just a random one of many) is a comparator which can work at 5V, and has a push-pull output, which means that it can force the output to 0V or 5V (the comparator's supply voltage). Note that there are many comparators which have an open collector output instead, they need a pull-up resistor to get the 5V.
Also note that the 0V and 5V outputs are not always met. You need a RRIO (Rail-to-Rail I/O) device, and even then the output may be a few tens of millivolts short of the theoretical value.

edit: Comparator tutorial  



An analog comparator is a device with 2 inputs, +, called the non-inverting, and -, called the inverting, and one output. It continuously compares the input voltages on the + and - inputs. If the + input has a higher voltage the output will go to the positive power supply voltage (in our case +5V). If the voltage on the - input is higher the output will go to the negative power supply voltage (in out case 0V).
So you put the - input to 2.5V by means of a resistor divider.
If the + input is 3V it's higher than the - input and the output will go to +5V. If the + input is 2V it's lower than the - input and the output will go to 0V. This should be easy to remember: the input with the highest voltage wins, and the output goes to that level. So if the + input is the highest, the output goes to the + power supply level.  

Hysteresis (a bit more complex)
Olin mentions hysteresis, and it may be important, but it's a bit more complicated. You probably won't need it if the input voltage will never be around the threshold voltage (the voltage where it switches from + to - and vice versa). If the input voltage can be close to the 2.5V reference it may cause unwanted effects. Noise on the input voltage may cause it to go above and below the 2.5V all the time, and therefore cause the output to switch fast between 0V and 5V.  



Engineers have invented hysteresis to prevent this. It means adding a small portion of the output to the input, so that the voltage comparison will be different depending on the output level too. Instead of a single threshold at 2.5V we'll have two threshold levels, for instance 2.4V and 2.6V. If your input starts from 0V and slowly goes up, the output will toggle when the upper threshold of 2.6V is reached. But when going down again the other threshold is valid, and the voltage has to go below 2.4V to toggle again.  



This means that continuous toggling of the output won't happen anymore, unless your noise will be larger than the 200mV hysteresis (very unlikely).



Further reading:
Adding Extra Hysteresis to Comparators (Maxim Application Note)