Even before the atomic bombing of Hiroshima and Nagasaki, the war situation had developed not necessarily to Japan's advantage. Allied forces had been taking island after island, and were firebombing dozens of cities to the ground. So I assume the atomic bombing of Hiroshima and Nagasaki wasn't the sole cause of Japan's surrender. But did it contribute to Japan's surrender?
A sizeable proportion of Americans apparently believe that the bombing contributed to Japan's surrender. Even some who disapprove of the atomic bombing think it contributed to Japan's surrender. From Majority Supports Use of Atomic Bomb on Japan in WWII, 57% approved of the bombing and 38% disapprove, and 80% think that the bombing saved American lives, so at least 18% (38 + 80 - 100) both disapprove of the bombing and think it saved American lives. (As a side note, at the time of the war, there was some public sentiment in favour of more bombing regardless of whether it was necessary: 22.7% of the population in December 1945 wished more bombs had been dropped before it could surrender)
I've come across articles claiming that the atomic bombing didn't contribute to Japan's surrender, but they've usually been by people with some potential bias against the bombing. For example I've read (the now paywalled) The Bomb Didn't Beat Japan - Stalin Did (referring to the USSR's war against Japan) which, according to a commentcomment in the question "How many lives were estimated to have been saved by the Hiroshima and Nagasaki bombs?", was by a lifetime opponent of nuclear weapons.
The question http://history.stackexchange.com/q/10218/421How many lives were estimated to have been saved by the Hiroshima and Nagasaki bombs? is related, but it's assuming that the atomic bombing contributed to Japan's surrender, and is asking about the costs and benefits of doing it.