There is only one hotel at Machu Picchu itself and that is the Belmond Sanctuary Lodge Machu Picchu. It will cost you to stay there, as it's an exclusive property owned by the Belmond Company, the same outfit that operates PeruRail, but it's also the only place you can sit in a Jacuzzi and look at the Inca city long after the crowds have left. In Aguas Calientes, you'll find many hostels and cheaper hotels lining the railroad tracks—that's not as down-at-the-heels as it first sounds: many rooms have great waterfront views. Aguas Calientes' budget lodgings are utilitarian places to lay your head, with a bed, a table, a bathroom, and little else. A handful of hotels offer surprising luxury for such an isolated location. Their rates can be shockingly luxurious, too.
All hotels collect guests just outside the front gate of the station. Lodgings keep surprisingly early checkout times. (Hotels free up the rooms for midmorning Cusco–Ollantaytambo–Machu Picchu trains.) Unless you are staying in one of the more expensive hotels, expect to vacate by 9 am, though this is less strictly enforced in the off-season. All hotels will hold your luggage if you're not leaving town until later in the day.
Many hotels keep the same official rates year-round but unofficially discount rates during the off-season, which can be anywhere from mid-November through March. It also pays to check the hotel website, if it has one, for current promotions.