There can be many causes of constipation in young babies and children. The physicians who will be best qualified to help you with this issue include your pediatrician
or your family medicine doctor
Many cases of constipation in infants are known as 'functional constipation' - meaning that there is no serious underlying medical cause. Infant dyschezia is a common variant in which the child strains and cries before passing a normal, soft bowel movement. This form of 'constipation' is caused by the infant fighting against the urge to have a bowel movement and resolves as they learn to accept this normal body function.
When the infant fusses and cries before passing hard pebble-like stools, this is more consistent with non-functional constipation. Non-functional constipation can be causes by food allergies or intolerance (say, to cow-milk formula) and dehydration.
Rarely, constipation can be caused by more serious underlying conditions, such as anatomical problems with the rectum or anus, Hirshprung's disease (a nerve problem of the colon) or thyroid dysfunction.
As always, diagnosis and treatment of your child's condition will require examination by your personal physician. Scheduling an appointment with your pediatrician or family medicine doctor is recommended.