A late engine problem cost Felipe Massa the Hungarian Grand Prix and another chance to lead Formula One's overall standings. What the Ferrari driver _ and his team _ didn't lose was confidence.

Massa was cruising toward his fourth win of the season Sunday, after a bold overtaking move at the start, only for his engine to give out three laps from the checkered flag. That allowed McLaren's Heikki Kovalainen to earn his first Formula One victory.

Ferrari's performance had come under scrutiny following a questionable run of results, but Massa's performance _ and Kimi Raikkonen's third-place finish _ will help subdue any doubts.

"We still need to push very hard in the development of the car and the reliability. But even in a worse case like this, we're still in the championship, completely," the 27-year-old Massa said. "We're still in the fight. We'll be pushing very hard over the break."

Massa's disappointment was all the greater after his superb start, when he powered around Kovalainen from third before beating pole sitter Lewis Hamilton in a straight race around the second corner for the lead.

After a tire puncture dropped Hamilton back into 10th place, Massa built a 15-second lead over Kovalainen.

Needing only to parade home for his ninth career victory, things blew up for Massa.

"We are very sad for Felipe because he did, in my view, the best race of his career today," Ferrari team principal Stefano Domenicali said. "It was fantastic in the way he attacked and the way he managed the race. So we are very disappointed for that."

Massa emerged from the cockpit of his stalled car, hands over his helmet in disbelief as he watched.

"I think I'm still growing a lot and learning race to race, and that can help for the championship _ the confidence _ and that's the most important thing," Massa said. "I think for the moment everything is completely open, we have three cars in a very small gap in terms of points."

Hamilton held a 17-point advantage over Raikkonen with two races to go last season, and still managed to lose the title by one point to the Finn.

Domenicali said Massa would have no problem getting over Sunday's race.

"He's very strong. For sure, this kind of race, if you're able _ mentally _ to manage after the disappointment you have, you will only get stronger," he said. "And this is what we're going to do together, because that is the way we are going to approach the next race in Valencia."

Defending F1 champion Raikkonen had his best result since a runner-up finish at the French GP in June but was still unhappy with his car's performance, which excelled in open road but got bogged down in traffic too often.

"When the track is clear we showed that we have the speed. When there is traffic, we can't take advantage," Domenicali said.

Raikkonen, who set the race's fastest lap at 1 minute, 21.195 seconds, couldn't challenge Toyota's Timo Glock for second down the stretch because of a problem with the rear of his car.

"It was a disappointing weekend for me but at least I managed to come away with a decent result," said Raikkonen, who trails Hamilton by five points in the championship fight. "We had good speed in the race and without the mistake in qualifying it would be better."

Domenicali said it was unacceptable that both cars malfunctioned, especially with a street circuit race coming up at the European GP on Aug. 24.

"We cannot accept these kinds of problems. We are paying too much of a price for this," Domenicali said. "Qualifying is crucial and the difference today was that on one side (Massa) we are able to jump in front and race like we were able to do and on the other hand (Raikkonen), in the middle of the field, it was nearly impossible to do something."