The Japanese high command was split into those who wanted to sue for a diplomatic peace and the militarists who wanted to pursue a strategy of bleeding out the Allies, with the hope that they would grow tired of furthering the war as their casualties mounted.
Prior to the use of the atomic bombs and the Soviet declaration of war, the militarists maintained a slim majority in the Japanese high command. The atomic bombs and/or the Soviet declaration of war gave the diplomatic party enough leverage to gain the upper hand. So there were those on the high command who were searching for a politically-acceptable, diplomatic way out of the war (they wanted an assurance of the continuity of the imperial house, which the USA would not give), but they were not in a position to fully implement this plan in early August 1945. There are those who speculate they may have been in a place to do so even before the planned US invasion in November 1945, with or without a bomb (or Soviet invasion), but it's not an easy thing to know.
See Hasegawa's Racing the Enemy for a lot more discussion.