The perpetrators arrived at a cemetery in the central city of Kaolack on Saturday evening searching for the grave of a man buried the day before, the public prosecutor said.
Media reported that they targeted the body because the man was gay, though this was not mentioned in the prosecutor's statement and has not been verified by AFP.
Videos widely shared on local and social media show people gathered around a large fire, filming the scene on their phones.
Senegalese law deems gay sex "against nature" and punishes it with imprisonment of up to five years.
Homosexuality has never been widely accepted in Senegal, but the incident allegedly committed on Saturday night has been viewed by many as an assault on the respect due to the dead.
Senegal's judiciary on Sunday said it was opening an investigation to identify and punish the perpetrators of the "barbarity."
A local police official told AFP four people suspected of "being among the masterminds" were arrested on Monday in Kaolack, confirming, on the condition of anonymity, information from a press release, without giving further details.
Although very uncommon, it was not the first time the body of someone thought to be gay has been exhumed in Senegal.
At least two cases were documented in central and western parts of the country from 2008 to 2009, but AFP has found no recent record of public cremation.
Amnesty International Senegal, along with two Senegal-based human rights organizations, "vigorously condemned" the incident in a statement, adding that it "violates the dignity of the deceased and his family."
Amnesty has long-decried the deteriorating situation for the country's LGTBQ community, many of whom are forced to hide their identity or live abroad to avoid persecution.
In 2021, the majority of the 1,300 Senegalese asylum applications in France cited persecution over sexual orientation, according to official figures.
Many in the Muslim-majority West African nation believe being gay is a Western lifestyle being imposed on their society, with occasional anti-LGBTQ demonstrations calling for tougher legislation.
Several media reported the deceased man's family had first sought to bury him in Senegal's holy city of Touba, but allegations of him being gay had preceded his burial and permission had been refused.
His relatives had then tried to bury him near his home, but the neighborhood had objected, until they eventually dug a grave for him at the cemetery in Kaolack.
Serigne Cheikh Tidiane Khalifa Niasse, who heads a local branch of the influential Tidianes religious brotherhood, condemned the acts in Kaolack.
Powerful Sufi brotherhoods hold considerable social and political clout in Senegal.
The religious leader in a statement expressed his "profound indignation and categorical condemnation of the reprehensible act that was committed against an individual for whom we have no responsibility whatsoever in terms of his private life."
"This act can in no way be justified or tolerated," he added.
An official from the group "And Samm Jikko Yi" (Together for the Safeguarding of Values), which campaigns for harsher punishments for gay sex, also deemed the "mob justice regrettable."
But he blamed the Senegalese state, which he said gave the impression of over-protecting the LGBTQ community, sparking a backlash.