Top Gear sparked a minor diplomatic incident when it described Mexicans as "lazy, feckless, flatulent [and] overweight" but the BBC2 programme fronted by Jeremy Clarkson has been cleared of breaching broadcasting regulations by media regulator Ofcom.

The watchdog said the comments, in an episode of the programme broadcast on 30 January this year, had the potential to be "very offensive" but were justified by the programme's "irreverent style and sometimes outspoken humour".

Ofcom said Top Gear "frequently uses national stereotypes as a comedic trope and that there were few, if any, nationalities that had not at some point been the subject of the presenters' mockery throughout the history of this long-running programme".

As an example, Ofcom said the same edition of the programme had poked fun at Australians who were "ridiculed for various national traits" in a competition between the programme's UK and Australian presenters.

The controversial exchange between Clarkson and his fellow presenters Richard Hammond and James May centred around the launch of a new sports car from Mexico which they joked was called "the Tortilla". They went on to describe Mexican food as "like sick with cheese on it" and "re-fried sick".

Clarkson added: "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 [slumps in seat and snores]. They won't complain. It's fine."

But the Mexican ambassador in London did complain to the BBC about the programme, branding it "xenophobic" and "offensive", while Ofcom received a total of 157 complaints.

Ofcom said in its ruling on Monday that the programme was "light-hearted in tone" and typically included "quirky and humorous banter between the presenters".

"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," it added.

"Humour can frequently cause offence. However, Ofcom considers that to restrict humour only to material which does not cause offence would be an unnecessary restriction of freedom of expression."

The BBC apologised to the Mexican ambassador five days after the programme aired, saying the comments may have been "rude" and "mischievous" but there was no "vindictiveness" behind them.

The controversial comments were later cut from the programme for its US broadcast.

One of the BBC's biggest hits and sold to broadcasters around the world, Top Gear is no stranger to controversy.

Hundreds complained after Clarkson made a joke about lorry drivers murdering prostitutes shortly after Steve Wright, a forklift truck driver from Ipswich, was jailed for killing five young women who worked as prostitutes.

And the programme was censured by the BBC Trust's editorial standards unit three years ago when its presenters were filmed drinking while driving in the Artic for a special "polar" edition.

Clarkson was also criticised in 2009 for calling former prime minster Gordon Brown a "one-eyed Scottish idiot" while hosting a stage version of the show in Sydney.

• To contact the MediaGuardian news desk email editor@mediatheguardian.com or phone 020 3353 3857. For all other inquiries please call the main Guardian switchboard on 020 3353 2000. If you are writing a comment for publication, please mark clearly "for publication".

• To get the latest media news to your desktop or mobile, follow MediaGuardian on Twitter and Facebook