If it is possible to define a particular surface in the three-dimensional space as [math]f(x, y, z) = c[/math], then we can define a contour on the surface by parametrization as [math]x(t), y(t), z(t)[/math]. Then, we have for all points in the contour,
[math]f(x(t), y(t), z(t)) = c[/math]
Let us calculate the total differential for [math]f(x(t), y(t), z(t))[/math] with respect to [math]t[/math]. We obtain
[math]df = \dfrac{\partial f}{\partial x}\mathrm{d}x + \dfrac{\partial f}{\partial y}\mathrm{d}y + \dfrac{\partial f}{\partial z}\mathrm{d}z [/math]
[math]= \left(\dfrac{\partial f}{\partial x}\mathbf{i} + \dfrac{\partial f}{\partial y}\mathbf{j} + \dfrac{\partial f}{\partial z}\mathbf{k}\right).(\mathrm{d}x\mathbf{i} + \mathrm{d}y\mathbf{j} + \mathrm{d}z\mathbf{k})[/math]
But since [math]\mathrm{d}f = 0[/math], we conclude
[math]\left(\dfrac{\partial f}{\partial x}\mathbf{i} + \dfrac{\partial f}{\partial y}\mathbf{j} + \dfrac{\partial f}{\partial z}\mathbf{k}\right).(\mathrm{d}x\mathbf{i} + \mathrm{d}y\mathbf{j} + \mathrm{d}z\mathbf{k}) = 0[/math]
The first of the factors defines [math]\mathbf{\nabla}f[/math] while the second defines a vector tangential to the contour. That their dot product is zero implies that they are perpendicular.