In this paper, we study the optimal control problem with terminal and inequality state constraints for state equations described by Volterra integral equations having singular and nonsingular kernels. The singular kernel introduces abnormal behavior of the state trajectory with respect to the parameter of α ∈ (0, 1). Our state equation is able to cover various state dynamics such as any types of Volterra integral equations with nonsingular kernels only, fractional differential equations (in the sense of Riemann-Liouville or Caputo), and ordinary differential state equations. We obtain the well-posedness (in L p and C spaces) and precise estimates of the state equation using the generalized Gronwall's inequality and the proper regularities of integrals having singular and nonsingular integrands. We then prove the maximum principle for the corresponding state-constrained optimal control problem. In the derivation of the maximum principle, due the presence of the state constraints and the control space being only a separable metric space, we have to employ the Ekeland variational principle and the spike variation technique, together with the intrinsic properties of distance functions and the generalized Gronwall's inequality, to obtain the desired necessary conditions for optimality. In fact, as the state equation has both singular and nonsingular kernels, the maximum principle of this paper is new, where its proof is more involved than that for the problems of Volterra integral equations studied in the existing literature. Examples are provided to illustrate the theoretical results of this paper.