Ferrari’s Sebastian Vettel was fastest in second practice at the Bahrain Grand Prix with the Mercedes and Red Bull teams close behind.
The German was only 0.041 seconds quicker than Mercedes driver Valtteri Bottas.
Red Bull’s Daniel Ricciardo was third with Ferrari’s Kimi Raikkonen and Lewis Hamilton’s Mercedes behind him.
But after managing to crawl back to the pits, Ferrari fixed the car and he was able to complete his work.
The four-time world champion said: “It was not the best day for us, we still need to improve the car. The car feels good. On one lap it was OK. Long run we might be quite a bit behind, but I am sure we can improve for tomorrow.”
It was the second technical problem for Ferrari, after Raikkonen broke down with a turbo overheating problem in the first session. The Finn needed a new internal combustion engine to be fitted as well ahead of the second session.
Hamilton’s true pace was not seen – he had a messy session and set his lap when his tyres were older than his rivals’.
Hamilton aborted his first lap, was blocked by Renault’s Nico Hulkenberg on the next and finally nailed a time on his third attempt, when the edge would have gone from the rubber.
He and Vettel are tied on points at the top of the championship after a win and a second place apiece in the first two races of the season in Australia and China.
The pattern of the season so far in qualifying has been Hamilton on pole by a small margin, with Vettel and Bottas second and third separated by thousandths of a second.
Conditions are very different in Bahrain compared to Melbourne and Shanghai and Hamilton is concerned that Ferrari will be faster in the desert as a result of what he expects to be their lighter demands on the tyres.
On the race-simulation runs, Hamilton appeared to have a small advantage over the other drivers on the super-soft tyres and the soft tyres – other than two very quick laps by Raikkonen on the softs right at the end of the session.
But Hamilton said he had been told Ferrari were quicker than Mercedes in race pace.
“I didn’t get to finish my lap. I would hope I would be in amongst [the top three if I had],” he said.
“Ferrari’s race pace is a couple of tenths faster than ours. We have to work out how we are going to close that gap.
“The car did not feel spectacular on the long run. There are some things we have to work on just with the tyres. But it could all be different on Sunday.”
The stage seems set for a very close race between Mercedes and Ferrari, with Red Bull much closer on raw pace in the dry than they have been so far this season.
Red Bull team boss Christian Horner told BBC Sport the team had made some changes to the car and it had been “a positive day”, especially for Ricciardo.
“We have hopefully closed that gap a little bit. Hopefully we can build on that through the weekend,” he added.
Behind the big three, Hulkenberg was an impressive sixth fastest for Renault, ahead of Felipe Massa’s Williams.
Hulkenberg’s team-mate, Englishman Jolyon Palmer, was a second off the German in 13th place, just ahead of the McLaren of Fernando Alonso.
Red Bull’s Max Verstappen was only eighth fastest but on his qualifying simulation his floor was damaged by a small wing that had come off Bottas’ Mercedes. The Dutchman looked relatively competitive on his race runs.