DAKAR, Senegal — Hundreds of mercenaries from South Africa and other countries are playing a decisive role in Nigeria’s military campaign against Boko Haram, operating attack helicopters and armored personnel carriers and fighting to retake towns and villages captured by the Islamist militant group, according to senior officials in the region.

The Nigerian government has not acknowledged the presence of the mercenaries, but a senior government official in northern Nigeria said the South Africans — camped out in a remote portion of the airport in Maiduguri, the city at the heart of Boko Haram’s uprising — conducted most of their operations at night because “they really don’t want to let people know what is going on.”

He said the mercenaries’ role was crucial, part of a new offensive against Boko Haram after a nearly six-year insurrection. The Nigerian military, under pressure because of a presidential election to be held this month, has recently claimed a string of successes against Boko Haram, boasting about the recapture of a number of towns.

The mercenaries “are in the vanguard in the liberation of some of the communities,” the official said, speaking on the condition of anonymity for fear of reprisals.