In February, the Mexican Ambassador complained to the BBC after Top Gear presenters Jeremy Clarkson, James May and Richard Hammond described Mexican people as "lazy, feckless, [and] flatulent".
In a segment on a new sports car from Mexico, May said that Mexican food was "like sick with cheese on it", while Clarkson claimed that all Mexicans were lazy.
He said: "That's why we're not going to get any complaints about this - cos the Mexican Embassy, the Ambassador's going to be sitting there with a remote control like this (slumped in seat and snoring). They won't complain. It's fine."
However, the ambassador did complain, along with 157 viewers, that the comments were offensive, derogatory and tapped into negative racial stereotypes.
Ofcom considered the complaints against Rule 2.3 of the Broadcasting Code, which states: "In applying generally accepted standards broadcasters must ensure that material which may cause offence is justified by the context…"
Ofcom recognised that the comments were based on negative national stereotypes about Mexican people that would be offensive to viewers.
However, the regulator noted that Top Gear is known for its "irreverent style and sometimes outspoken humour", including repeated mockery of national identities.
For example, the same episode featured a competition between the UK Top Gear presenters and their Australian counterparts, throughout which the Australians were consistently ridiculed for their national traits.
"In this instance, therefore, Ofcom considered that the majority of the audience would be familiar with the presenters' approach to mocking, playground-style humour, and would have considered that applying that approach to national stereotypes was in keeping with the programme's usual content, and the presenters' typical style," said Ofcom.
"Ofcom was of the view that the majority of the audience would therefore be likely to have understood that the comments were being made for comic effect."
Ruling that Top Gear did not breach rule 2.3 of the Code, the regulator also noted that to "restrict humour only to material which does not cause offence would be an unnecessary restriction of freedom of expression".
Last week, Hammond admitted his regret at the "misunderstanding" over the Mexico comments, claiming that he was merely trying to portray himself as "actually believing the images of Mexicans I received from Westerns were accurate".