When Nico Rosberg retired after winning title in 2016, Bottas was the man drafted in to replace him, but he struggled to match Hamilton's performances in his first two seasons and occasionally found himself in a support role as his teammate battled Sebastian Vettel and Ferrari.
Bottas has revealed he was on the verge of turning his back on the sport for good.
"At the end of 2018 I almost stopped. It was so close," Bottas told Motorsport Magazine's "My Big Break" podcast.
"Just because of the fact I couldn't understand and take in the fact I couldn't beat Lewis in those two years. I put so much pressure on myself. Towards the end of '18, especially when I started to have the support role, I really couldn't take it, I really struggled. It was not fun."
When asked whether he meant retire from F1 altogether, not just leave Mercedes, Bottas said: "Yes, absolutely. I was done.
"The human mind is strange in a way, sometimes you go into dark places and you lose the joy on things. I lost the joy of F1 and racing in F1.
"I was almost angry to F1, it's weird. I just needed some time off. Think things in a big picture and realised it's a pretty cool sport and I still have great opportunities ahead of me."
Bottas said the click to stay happened when he was walking in a Finnish forest in January 2019, just weeks before preseason testing for the new season would resume.
The decision to stay was vindicated. Bottas' 2019 season is considered his best as Mercedes and it started with a win at the opening race, the Australian Grand Prix.
Bottas memorably marked the victory with the radio message, "to whom it may concern, f--- you", which he admits in the podcast was as much aimed at himself and the negativity he had allowed to creep in as it was to any of the critics who said he should not be racing in what was F1's most coveted race seat.
"Now when I look back at it was a great school for me, I learned a lot about myself, to give myself more of a leash, not to be too hard on myself. But learned so much about everything that I'm really glad it happened.
"Those kind of moments, I just want to tell people to always look at the big picture in life. If you feel a bit anxious in life, take a step back, there's always so much more to get if you don't give up."