Mercedes brought a raft of updates to Barcelona for the Spanish Grand Prix, but Hamilton said he was still struggling with the W13 car in qualifying, leaving him sixth on the grid.
Contact with Haas driver Magnussen on the opening lap caused Hamilton to slow and forced him into an early pitstop, leaving him over 50 second off the leader at the end of the opening lap.
Hamilton asked Mercedes over the radio if it would be worth saving the engine on his car, only to be told that he could still finish as high as eighth.
But Hamilton ultimately clawed his way back up to fifth at the chequered flag, having only lost fourth place to Carlos Sainz in the closing stages when a water leak forced him to slow down.
Hamilton explained that the race pace was "much better" and the car felt "much nicer" over the long runs thanks to the updates, giving him reason to think he could have been in the mix with the Red Bulls that finished first and second in a normal race.
"This is a great sign that we're going in the right direction," Hamilton said.
"I have no doubt at some stage [we can fight for wins again] because today, if I hadn't had that, I'd have been fighting with the Red Bulls.
"So that gives me great hope that at some stage we'll be fighting for the win."
Hamilton added that Mercedes had "experimented something" on teammate George Russell's car that "ultimately ended up being the better way to go in qualifying", meaning he would "probably take that on" from the next race in Monaco.
He managed to pull off a number of overtakes as he cut his way through the field, running a three-stop strategy that included a late charge on softs. He was able to pick off Esteban Ocon, Valtteri Bottas and Sainz in the final stint, only to then lose fourth to Sainz due to the issue.
Hamilton felt that race charging through the field was "like a win" and "actually feels better most often than a win, when you've come from so far back and been through so much."
Hamilton revealed that a conversation with a terminally-ill child on Saturday had served as inspiration for him through Sunday's race.
"Ultimately there was quite a bit of adversity in that race, starting so far back," Hamilton said.
"There was a girl that I spoke to yesterday, who was my little inspiration, Isla, a five-year-old that's terminally ill and she said can you win the race for me tomorrow.
"I said I don't know if I can win the race, but I'll give it everything. So hopefully for me, that was a bit like a win, and I dedicate it to her."