Lewis Hamilton, Sebastian Vettel
Formula One - F1 - Spanish Grand Prix - Barcelona-Catalunya racetrack, Montmelo Spain - 13/05/17 - Mercedes' Lewis Hamilton and Ferrari's Sebastian Vettel after the qualifying session. Reuters / Albert Gea

Mercedes F1 star Lewis Hamilton has revealed that he nearly walked away from the sport before his ongoing rivalry with Ferrari's Sebastian Vettel. Hamilton, having registered seven Grand Prix victories this season, is embroiled in a heated battle with Vettel for the Formula One World Championship.

Though Hamilton leads Vettel by 28 points, Ferrari has proven to be quicker than Mercedes at various junctures of the season, giving the German a glimmer of hope to make up lost ground. With six races left in the 2017 Formula One season, a pair of victories should seal a fourth world title for Hamilton. Vettel, already a four-time World Champion, is trying to bring the Scuderia its first title since Kimi Raikkonen in 2008.

After winning two of his three titles in the last three years, Hamilton began seeking motivating to continue in the sport. In June, he broke childhood idol Ayrton Senna's record for most pole positions and has now set his sights on Michael Schumacher's record of 91 Grand Prix victories. The Briton has credited Vettel for renewing his motivation to dominate the sport.

Lewis Hamilton considered retirement before 2017 season

"There's been talks about it (retirement) and I definitely have thought about it and there's been times when I've thought there's other things I want to do, but then we're in the heat of this battle right now and I'm loving it more than ever. The training, all the work that you put into something, and then you get to really show your abilities. It's the greatest feeling ever so I'm going to keep going for as long as I can and see what I can do," Hamilton said ahead of the Malaysian Grand Prix.

At some stage, the 32-year-old Hamilton hopes to pursue other interests outside of Formula One. "When you're in Formula One you're in the spotlight, you're at the top of the world, then it's downhill from then on -- you don't earn the same money, there's not a huge amount of opportunities because you've been in that world for so long. I've been there since I was eight.

"For me at the moment, for these past five, six years I've really been trying to work on what I enjoy outside of the sport so that when I stop I can walk away and still have other things ... every year I'm always assessing the plan," Hamilton added. The 2017 Formula One season continues with the Malaysian Grand Prix at Sepang International Circuit between Sept. 29 and Oct. 1.