The Briton had started from pole position and was keeping Sebastian Vettel's Red Bull at bay when he suffered a gearbox problem on lap 22.
The retirement meant Hamilton has dropped from second to fourth in the drivers' championship.
The McLaren driver had no doubts he had the pace to win the race comfortably.
"It's heartbreaking not to have finished the race today," said Hamilton.
"We definitely had the pace to win this weekend. In fact, before I retired, I was cruising; just managing the gap back to Seb.
"Then I started to experience difficulty with the gearshift, then I lost third gear, and then the 'box kept dropping into neutral."
Hamilton is now 52 points behind championship leader Fernando Alonso with six races to go.
Although he concedes it will be hard to beat his rivals to the title, Hamilton insisted he is determined to fight until the end.
"Obviously, I was disappointed, but the good thing we can take away from this weekend is that we have extremely good pace," he said.
"As a result, I think we can really attack in the next few races. It's going to be hard to close the gap to guys like Fernando [Alonso] and Sebastian, especially when they keep finishing race after race, but I'll never give up.
"There are six more races, and I need to go and win all six. I'll fight until the end."