It was the seventh World Cup running that Brazil have reached the last eight, where they will now face Belgium or Japan, while Mexico have not made it to that stage since they hosted the tournament in 1986.
Mexico, who enjoyed an enviable recent record against Brazil having won seven of their previous 15 matches against them, were a threat on the counter in the first half but then faded without ever really being put to the sword. A glaring spotlight had been on Neymar after his opening three performances saw him miss a litany of chances, frequently squander possession and spend far too long on the turf. Yet he answered a number of questions with a much more positive display and a decisive finish early in the second half from a move that he had started himself, although his propensity for histrionics were again in evidence.
They will have to do without defensive midfielder Casemiro in the quarters, however, after he picked up his second booking.