The dynamics of a pair of point vortices of opposite signs in a rectangular domain is investigated in the whole range of energies. This simplest nonintegrable system reflects important features of different vortex flows: Bénard convection, Görtler vortices, flow in a cavity etc. In contrast to an approximate "cloud-in-cell" method that has been used for many vortices, the exact equations of motion for an arbitrary system of point vortices in a rectangle are derived and applied to the particular case of a pair of vortices. Patterns of periodic, quasiperiodic, chaotic and billiards-type motions are revealed for generic cases and two limiting cases: two close vortices (near-dipole) and a vortex close to the boundary. New criteria of ergodicity are introduced, and it is found that some chaotic motions are close to, in some sense, ergodic ones.