This has always bothered me. In the comics and cartoons Spider-man started to lose his powers because his mutation started changing him. In the movie it seemed like it was his self-esteem which makes no sense to me really. Is there any reason why Spider-man lost his powers?
In the movie the reason spidey loses his powers is the more enigmatic part. I will try to explain my take on this by taking a closer look at his scenario step by step.
In the movie we see a relatively younger spiderman (people who rescue him from the train fight remark that he is still a kid) who despite his IQ level shown in Spider man 2 (for identifying the flaw with Doc Ock's initial demonstration) is still not the financially secure guy because he is in school and delivering pizza (which is not the ideal job when trouble brews in town) and unlike Batman he doesn't have Lucius Fox or Alfred in his life to cover his appearance or managing the financial aspect of his life when he is the vigilante
Because of him being the vigilante his relationship with MJ gets strained initially in the movie and she ends up getting engaged to someone else, Plus the burden of his uncle's death seems to have a bearing on him until he confessed the truth to his aunt and on top of that the very photographs he takes for his work were used to showcase him being the bad guy by the Daily Bugle. These all add up leading to the stress which makes him doubt his own powers and destiny leading him to make the decision to quit being the hero.
So once he makes the decision i assume he wasn't able to exert the control on his powers like he would normally when he has more belief in his ability and the responsibility it carries with it which led him to lose it.
PS: This question has a more open ended scope to it and I would love to hear other opinions as well and I can try to clarify if anyone has any doubts.
I will try to answer it by my own thoughts. In one line, the answer is: The main reason behind his losing powers was he started to hate himself because he could not balance between his normal life and criminal-hunting life anymore. This hate was not explicit, but it existed silently in his inner heart. He was economically weak. So he had to sell Spiderman's pictures reluctantly. He could not attend the classes timely. He even lost his job in the pizza bar which was very necessary for him. His love life was not successful. So sometimes he felt his life was being wasted serving society, chasing criminals and in the meantime he forgot to think about himself. So he started hating his life (again not explicitly). But we saw when he lost his power, he was not hurt at all. In fact he loved his new life. There was no responsibility for others. He could give time for himself and tried to fill the blanks in his life. As in the movie, the power of throwing webs remain is in his body, so I guess he needed enthusiasm, energy and will power to produce and throw webs. But when he started hating his powers, he lost his enthusiasm, motivation and will. As a result, he lost his power.
But when Octavius attacked Mary Jane, he got back his motivation. So he got his power back again. He got his love back too. He finally understood what it means:
Early on in the film, before he's turned into a supervillain, Octavius has Peter over for dinner. His wife, Rosie, asks Peter if he has a girlfriend, to which he answers he doesn't know, prompting Octavius to advise, "Love should never be kept secret. If you keep something as complicated as love stored up inside, it could make you sick."
Peter first shows signs of losing his powers after missing Mary Jane's play and learning that she's seeing someone else. For the rest of the second act, he struggles with both the idea that he shouldn't be Spider-Man anymore and trying to convince himself that he's over Mary Jane.
Then, at the end of the second act, Doc Ock kidnaps Mary Jane. Peter, knowing now that he has to save her, realizes that he cares about her and his powers return.