See Nagell, Introduction to number theory, Theorem 107. Originally it was proved by Dirichlet.
An extended bibliography on negative Pell’s equation can be found in Gerasim, I.-Kh.I. On the genesis of Redei’s theory of the equation x 2 -Dy 2 =-1. (Russian) Zbl 0731.01014 Istor.-Mat. Issled. 32/33, 199-211 (1990) (available in electronic form).