We study reproducing kernel Hilbert and Pontryagin spaces of slice hyperholomorphic functions which are analogs of the Hilbert spaces of analytic functions introduced by de Branges and Rovnyak. In the first part of the paper we focus on the case of Hilbert spaces, and introduce in particular a version of the Hardy space. Then we define Blaschke factors and Blaschke products and we consider an interpolation problem. In the second part of the paper we turn to the case of Pontryagin spaces. We first prove some results from the theory of Pontryagin spaces in the quaternionic setting and, in particular, a theorem of Shmulyan on densely defined contractive linear relations. We then study realizations of generalized Schur functions and of generali...