While innerproduct's answer is correct, I always preferred a slightly different method for this type of problem, so I thought I should share.
I begin as he would, by integrating $\frac{\partial V}{\partial x} = -ay$ on both sides with respect to $x$ to get $V = -axy + g(y),$ where we use $g(y)$ as an arbitrary function of $y$ instead of a constant because this is what would vanish when taking a partial derivative with respect to $x.$
Then, instead of integrating our other expression, I would take derivatives with respect to $y$ on both sides: $\frac{\partial V}{\partial y} = -ax + g'(y).$ Now from the field we have $\frac{\partial V}{\partial y} = -ax,$ so $g'(y) = 0$ and $g(y) = C.$ Plugging this in we get $V(x,y) = -axy + C$ and we're done.
Sorry if this is considered a bit of a duplicate answer, but I just wanted to share my preferred method because personally, especially when this is generalized into higher dimensions, having all of those functions and checking that they all match up feels a bit messy and loose, and this feels a bit more elegant to me. (not a big deal either way though)