An American pastor abducted by armed men in South Africa has been rescued - and was "miraculously unharmed" in a deadly shootout.