I know this link is very old, but I thought I might chime in (despite the already progressed aging of this topic). You can in fact apply Fermat's principle to gravitational lensing. What you do is you start off with your general null-geodesic equation (which is the path light takes) parametrized with some arbitrary term, but make your parametrization in terms of time t and, assuming a weak-gravitational field with a static potential (by static I mean not moving anywhere), derive the effective speed of light. It should be something like v=1-2*|Phi| (which is 1 "minus" 2 "times" the absolute value of potential Phi). Which you can use the definition of the index refraction to get the index of refraction induced by your static potential. From here its pretty much a lensing problem. You can also prove light is deflected towards the source by applying Fermat's Principle in terms of your index of refraction (basically its the first variation of the integral from your source to observer along index of refraction n dl). Parametrize this in terms of your arbitrary parameter and you get the Lagrangian, and using the Euler-Lagrange equation you get that the infinitesimal change of the path light takes from its initial trajectory is just the perpendicular gradient of the natural log of the index of refraction... or approximating this it is just -2*"perpendicular gradient of"Phi. Integrating this (by the so-called Born Approximation you can just integrate from negative infinity to infinity) from you source to observer results in -4G/b*c^2 in the b-hat direction (this is in vector form). So, the direction light is deflected is toward the mass. I got a negative sign because I parametrized my unperturbed path of the light to be the x-direction and the mass to be the origin. Also, this is just a rough format at approaching the problem... a more proper way would be to compare the background geodesic, extended from the source to the observer, to that of a perturbed geodesic (Carroll's Intro. to GR does this)... but this formal process does not incorporate Fermat's Principle.
Basically, its good to remember that in Einstein's GR equation the energy-momentum tensor is in fact related to curvature of spacetime. Gravity corresponds to changes in the properties of space and time. It alters the straightest possible, or shortest, paths that objects naturally follow (including light!).