Massa visited the circuit medical centre after complaining of dizziness during Friday's second practice session.
Massa is hoping to be fit enough to race in the Belgian Grand Prix at the end of August, although he does have the benefit of the summer break to recover.
Di Resta, Williams' reserve driver, will therefore step in for the Brazilian driver and compete in qualifying.
He was cleared to continue by the FIA medical delegate on Saturday and took to the track for the final practice session before qualifying.
It was a Herculean task for the Scot because he had not raced in Formula One for 1,343 days or ever driven the new breed of cars.
His participation in qualifying later on Saturday will be his first since the season-ending Brazilian Grand Prix almost four years ago, and his only taste of this year's Williams will have been in the team's simulator at their Oxfordshire base.
Paul Di Resta turned up to the Hungaroring on Saturday morning, expecting to be in the Sky Sports commentary box.
Barbara Sinatra, wife of singer Frank Sinatra, dies at 90
She left Bosworth for California in her late teens after she was accepted to the Robert Edward School of Professional Modeling. Barbara became involved in supporting and raising funds for a number of charitable projects years after she married Sinatra.
With 10 points on his super license, Kvyat is now just two away from a race ban, and will remain so until the United States Grand Prix in Austin, Texas this October.
"It's weird. I was sitting talking about what we'd be saying in the qualifying build-up show, but diving straight in, I'm not going to lie, I was scared, I was nervous, anxious".
"I've not driven one of these cars for three-and-a-half years, apart from 10 laps I did in a 2014 auto, and then you get thrown into qualifying which is the deepest of all deep ends - it's like jumping off a cliff and seeing how you fight for survival".
"These cars are top of their game and it is like being back at home driving the best balanced vehicle you have ever driven".
Di Resta was seen heading into the Williams trucks during the session and the team appeared to be changing the pedals in Massa's vehicle - Di Resta is a much taller man than Massa and would need such a change. There's no pressure out there. The team prepared me as best as they could.
Williams said that modifying the vehicle for di Resta was not a big issue.
"But Paul is an experienced driver, and I couldn't feel happier actually that we have someone of Paul's calibre and experience, even though he may not have taken part in a race weekend for a couple of years".
Di Resta will be the third British driver on the grid this weekend alongside Lewis Hamilton and Jolyon Palmer.