SPIELBERG, Austria (AP) — Lewis Hamilton was in an upbeat mood after the Austrian Grand Prix on Sunday, despite losing ground on Formula One title rival Sebastian Vettel for the second straight race.

The Mercedes driver finished fourth in Spielberg, while Vettel powered his Ferrari to second spot to move 20 points ahead of Hamilton after nine races. In the previous race, two weeks ago in Azerbaijan, Hamilton was fifth and Vettel fourth.

Still, after starting from eighth place on the grid Sunday, Hamilton felt he got the best result possible in the circumstances.

"It was definitely a really good race. It was actually really positive and I don't think the points really reflect that," Hamilton said. "It's not great but it could be 30-something (point difference) today. Of course it's a hit when you take the penalty and start eighth instead of third, but it's not the end of the world. I got the best points I could."

Hamilton finished 1.4 seconds behind Red Bull driver Daniel Ricciardo, who took third place after holding off strong late pressure from Hamillton.

"I worked so hard to close the gap," Hamilton said. "He defended position really well, I don't think I could have done any better. "

Hamilton had the third fastest qualifying time behind Vettel and Mercedes teammate Valtteri Bottas, but was demoted five places for an unauthorized gearbox change after the last race in Azerbaijan, which Ricciardo won.

In Baku, Hamilton's chances of winning where effectively ended by a faulty headrest, which his team had to change during the race. Then came the grid penalty in Spielberg, where Hamilton was hampered by a faulty brake disc in final practice on Saturday.

But there is a steely streak in Hamilton that sees him thrive when things seem to conspire against him.

"It's an opportunity to grow and do something special. I'm genuinely happy with the way I've been driving, considering," he said. "It's important to understand that you can't be happy every day. You're going to be (unhappy) at one point because you put everything into it and sacrifice everything. It's hard to come out smiling and say 'That's fine' because it means you don't care, and the fact is I do care."

Mercedes head of motorsport Toto Wolff pledged to help Hamilton turn his luck around.

"I don't think there's a call for me to do anything else than I'm already doing, keep driving the way I have been and hope things get better," Hamilton said. "It's not like the team aren't on my side, or not working hard, or I'm not pushing them hard enough. The only way is to try and inspire them with the (kind of) drive I had today."

Meanwhile, Bottas took the win from pole position, narrowly fending off Vettel — who made a very strong late charge of his own — for his second win of a consistent season.

The Finnish driver's win puts him only 15 points behind Hamilton, opening up the possibility of a three-way title race when most observers had called it a straight battle between Hamilton and Vettel for the championship.

Hamilton is chasing a fourth F1 title, while Vettel is chasing a fifth. Bottas had never won a race before this season, but has done well.

"Valtteri did a fantastic job and thoroughly deserved to win today. There was never a point when he wasn't in the fight," Hamilton said. "I always assumed he still was and (this) just shows that he still is."

Given his recent travails, Hamilton could do with a change of fortune at his home race in Silverstone next weekend — the penultimate race before F1 takes its summer break.

"It's an intense battle; which I'm loving. I want to win the championship, but at the moment I'm 20 points behind," he said. "I don't have a crystal ball but it doesn't look great at the moment. It could switch within one race, but the bigger that gap gets the more the pressure builds."