Hi K., my son and I went through the same thing, so my heart goes out to you both.
I thought for the longest time that it was a "battle of the wills" and I was in for the long haul. However, after speaking with his pediatrician, I realized that there was more to it. This is what he recommended and it WORKED!
Reduce or eliminate foods from his diet such as, apples, cheese, bananas, bread/rice. These foods, although healthy, create a lot of "bulk" in his intestines and are harder pass. During this time period try to give him foods like dried apricots and prunes, beans, and fresh vegetables and plenty of water. Now here is the KEY to success for us, sprinkle Childrens Benefiber in his drinks and on his soft foods. It dissolves instantly and has NO taste. This extra fiber is what is going to make it easier and LESS PAINFUL for him to go potty on the toilet. After 2 weeks on this diet my son was going to the bathroom like a pro and we have NEVER had a problem since!
When it doesn't hurt to go potty the fear will go away and the natural order of things will resume. Good luck and God bless you both!