The Belgian, who has had a tough time at Old Trafford since he was signed by David Moyes nearly a year ago, pounced on a defensive mistake in injury time to ensure the Reds finished their pre-season programme unbeaten.
Darren Fletcher had put United ahead early in the second half, after Wayne Rooney had missed a penalty before the break.
Rodrigo equalised in Valencia’s best spell, but just as the friendly looked to be drifting to a draw, substitute Fellaini pounced for the deciding goal.
Louis van Gaal's first game in charge at Old Trafford saw the Dutchman unveil the 3-5-2 system that served him well so far in pre-season, but although United looked comfortable the game only came to life as a contest when Rooney struck his spot kick against the base of the post having been clipped going for an Ashley Young cross.
Fletcher put United ahead with a deflected shot from the 'D' on the edge of the box, but the Spanish side enjoyed a good spell midway through the second half, with Javier Hernandez heading a Rodrigo header off the line.
Valencia's former Bolton striker pounced when a Tom Cleverley clearance from a corner looped back over the defence, and seconds later Vinicius Araujo was inches away from getting a touch inside the six-yard box.
But Fellaini, one of a swathe of replacements, took full advantage when a defender and goalkeeper Diego Alves collided in stoppage time to roll the ball home with almost the last kick of the match.