I think that both will happen at almost exactly the same time, after the Singularity has occured.

http://en.wikipedia.org/wiki/The_singularity

If I had to absolutely claim that one would happen before the other, I believe that flying to Mars in the near future will be easier than establishing a base on the Moon. I`m not sure about actually walking on Mars though.