I have done both, more racing on foot than on the bike. There is no answer in my opinion. I have run a marathon, raced about a dozen half marathons, have raced many 5ks, and have done dozens and dozens of really tough running workouts on the track--such as 3 x 1200m at faster than 5k race pace with only 2 minutes rest between sets, mile repeats, 400m repeats at about mile race pace, a workout nicknamed the "Marquis de Sade," and tempo runs of 3-4 miles.
In my opinion running and mtb races hurt the same. It is all based on how hard you push yourself. Mountain biking doesn't beat up your body afterwards from all the pounding, like racing a marathon or half marathon. I've done marathon the shuffle down New York subway stairs the day after the race, had to have my wife help me get out of the bathtub after the race before going to dinner, and sat there at dinner staring at a bowl of soup without even being able to eat it.
But if you are really racing on a mountain bike it will hurt just as bad during the race. Your lungs will sear. Your whole body will burn with lactic acid buildup. Your legs will be screaming. In longer mtb races or rides at a hard effort, your feet and butt will hurt like hell. On the mountain bike, while you typically will recover faster because you don't pound the pavement for a few hours, there is the serious risk of injury associated with trying to negotiate technical terrain when putting in a race effort.
So I have done both and say there is no answer. They are the same. It is just how hard you push yourself. If you don't hurt on the bike like you do in a half marathon, well you can push yourself harder.
Lance Armstrong did say running New York was the toughest thing he has ever done. However, I've run New York and I'd say doing a century ride on the bike was harder for me. If you took an elite marathoner and had them train on the bike for a year, then had them ride one of the toughest stages of the Tour de France or a long-time trial, they would probably say the same thing Lance did--"that is the toughest thing I've done in my life." That is because Lance was not trained as well for a marathon as he was for the bike. (I read that his longest run in training for his initial marathon was something like 16 miles).