this just happened to my wifes phone. whe took it to the Apple store, and it turns out that there is a wire that sometimes comes loose under the home button. it will have to be opened up and moved. then it will work. the wire is just getting in the way of the button making contact with the internal sensor.
The same thing happened to me and I took it to Apple and it worked, I ended up getting a replacement because I had to go in for a second time because their fix didn't hold so They gave me another phone after I went back.