A power supply device for electric discharge machining, the device comprising: a voltage applying means (41, 42; 201, 203) for alternately applying positive and negative voltages across a machining gap between an electrode (45; 208) and a workpiece (46; 209) at intervals of not longer than one microsecond with a quiescent period equal to or longer than each voltage application period provided between individual voltage applications, a machining-gap open-state determining means for determining whether the machining gap between the electrode (45; 208) and the workpiece (46; 209) is in an open state or not before individual voltage applications, an average voltage detecting means for detecting an average machining gap voltage during machining, the average machining gap voltage being an average value of the voltages applied across the machining gap over a period from a preset reference time to a present time, an open-state counting means for counting a number of successive machining gap open states having the same polarity, and an applied polarity determining means (61, 65) for determining polarities of the voltages to be applied across the machining gap on the basis of the result of determination by the machining-gap open-state determining means, the average machining gap voltage detected by the average voltage detecting means, and the number of successive machining gap open states counted by the open-state counting means, wherein the voltages of the polarities determined by the applied polarity determining means are applied across the machining gap, and wherein the applied polarity determining means (61, 65) is configured such that, when the machining gap is in the open state before voltage application, the applied polarity determining means compares a preset maximum number of successive open states with the value counted by the open-state counting means and, if the value counted by the open-state counting means does not reach the maximum number of successive open states, the applied polarity determining means applies the same polarity as a last one across the machining gap, whereas if the value counted by the open-state counting means reaches the maximum number of successive open states, the applied polarity determining means applies a voltage of a polarity opposite to the last one; and wherein, when the machining gap is not in the open state before voltage application, if the average voltage detecting means detects a positive polarity, the applied polarity determining means (61, 65) determines application of a negative polarity as the polarity to be applied next and, if the average voltage detecting means detects a negative polarity, the applied polarity determining means determines application of a positive polarity as the polarity to be applied next. a voltage applying means (41, 42; 201, 203) for alternately applying positive and negative voltages across a machining gap between an electrode (45; 208) and a workpiece (46; 209) at intervals of not longer than one microsecond with a quiescent period equal to or longer than each voltage application period provided between individual voltage applications, a machining-gap open-state determining means for determining whether the machining gap between the electrode (45; 208) and the workpiece (46; 209) is in an open state or not before individual voltage applications, an average voltage detecting means for detecting an average machining gap voltage during machining, the average machining gap voltage being an average value of the voltages applied across the machining gap over a period from a preset reference time to a present time, an open-state counting means for counting a number of successive machining gap open states having the same polarity, and an applied polarity determining means (61, 65) for determining polarities of the voltages to be applied across the machining gap on the basis of the result of determination by the machining-gap open-state determining means, the average machining gap voltage detected by the average voltage detecting means, and the number of successive machining gap open states counted by the open-state counting means, wherein the voltages of the polarities determined by the applied polarity determining means are applied across the machining gap, and wherein the applied polarity determining means (61, 65) is configured such that, when the machining gap is in the open state before voltage application, the applied polarity determining means compares a preset maximum number of successive open states with the value counted by the open-state counting means and, if the value counted by the open-state counting means does not reach the maximum number of successive open states, the applied polarity determining means applies the same polarity as a last one across the machining gap, whereas if the value counted by the open-state counting means reaches the maximum number of successive open states, the applied polarity determining means applies a voltage of a polarity opposite to the last one; and wherein, when the machining gap is not in the open state before voltage application, if the average voltage detecting means detects a positive polarity, the applied polarity determining means (61, 65) determines application of a negative polarity as the polarity to be applied next and, if the average voltage detecting means detects a negative polarity, the applied polarity determining means determines application of a positive polarity as the polarity to be applied next.