The 31-year-old Scot started 58 races for Force India between 2011 and November 2013, with a best result of fourth place.
He was in Hungary anyway as a reserve driver and also as a replacement in the Sky Sports television commentary box for former racer Martin Brundle, who fell ill at Silverstone two weeks ago.
Massa had gone to hospital for tests on Friday after feeling unwell in practice but reported for duty on Saturday morning and was passed fit.
The team said he then decided to cut the final practice session short after 12 laps.
"He...has made the decision to withdraw from the weekend," Williams said in a statement.
"Williams supports Felipe’s decision and the team will work with him to ensure he makes a full recovery, with a view to return to the race track for the Belgian Grand Prix."
Di Resta has not driven the 2017 car before, other than in the simulator, but has driven a 2014 Williams. He faces a monumental task in being pitched straight into qualifying with no practice.
"You go straight in the deep end. It's a tricky little track. You have to be very committed and confident," he had said before the confirmation that he would be in the cockpit.
Di Resta will still be the more experienced man alongside 18-year-old Canadian rookie Lance Stroll.
"Paul is a very experienced, seasoned racing driver," said deputy team principal Claire Williams. "He competes in DTM (the German Touring Car championship), he's very close with the team and comes to every race with us.
"He takes part in every engineering briefing session and he was aware of this situation last night," she told reporters in the paddock.
"He's in debrief with the engineers now and is with Felipe. We're going to do everything we can to make sure in 60 minutes he's ready to take part this afternoon."
Massa had been due to leave Formula One at the end of last season but returned after Valtteri Bottas moved to Mercedes as replacement for retired 2016 world champion Nico Rosberg.
Hungary has been a race of special significance for the Brazilian since he suffered near-fatal head injuries after being hit on the helmet by a bouncing spring during qualifying in 2009.
The then-Ferrari driver spent several days in hospital in an induced coma after that incident.
(Reporting by Alan Baldwin, editing by Nick Mulvenney and Pritha Sarkar)
Share
