In a hydrogen generator according to the invention, a reformer temperature
sensor detects the temperature of a reformer at a start of a stop
operation of a hydrogen generator. In a controller, a processing and
controlling portion compares the detected temperature with first to
fourth reference temperatures pre-stored in a storage portion, and
determines which of the following conditions is the temperature condition
of the hydrogen generator at the stop; a first condition in which water
condensation occurs, a second condition in which water condensation and
carbon deposition are avoidable, a third condition in which carbon
deposition occurs, a fourth condition in which disproportionation
reaction occurs, and a fifth condition in which oxidization of catalyst
occurs. According to the determination result, an appropriate setting is
selected among first to fifth replacement settings pre-stored in the
controller corresponding to the first to fifth conditions, and an
internal gas replacement operation is performed according to the selected
setting.