There were two bombs, the first was dropped over Hiroshima on 6th August 1945 and the second over Nagasaki on 9th August 1945.
The Hiroshima bomb was based on Uranium and the detonation mechanism was fairly simple and well understood and required no testing prior to first use. Basically, two non-critical masses of Uranium were held at opposite ends of a gun. At detonation, one of the masses was fired into the other creating a critical mass and an atomic explosion. This bomb was relatively small and was known as "Little Boy".
The Nagasaki bomb was based on Plutonium and the detonation mechanism for this bomb was very complex. It had to be tested prior to first use to be sure it would work. This was the atomic bomb that was tested at Los Alamos on 16th July 1945. Basically, several non-critical masses of Plutonium were fixed in a sphere shape. At detonation, these masses were imploded together to create a critical mass and an atomic explosion. This bomb was quite large and wide and was called "Fat Man".
I think America was justified in using Little Boy. Thousands of American lives would have been lost in any invasion of the home islands of Japan. The taking of Iwo Jima demonstrated this clearly. The use of the Uranium bomb was therefore perfectly justified in order to end the war and save American lives.
The use of Fat Man over Nagasaki is less clear cut. I believe there was a desire within the US military to find out whether this weapon worked in actual use and not just in a test. The military knew they had only a few days in which to test this bomb, once Japan surrendered they'd never get another opportunity. I think there was therefore a lot of pressure to use the Plutonium bomb, not just to save American lives and end the war, but also to test a theory.
In short; the use of the Hiroshima bomb can be justified as having saved American lives and helping to end a prolonged and bloody war. The use of the Nagasaki bomb is questionable, both in military and humanitarian terms.