CARACAS, Venezuela — Dozens of activists in Venezuela whom opponents of the government considered political prisoners were released from prison on Friday in what the authorities called a gesture aimed at uniting the fractured nation.

Among the 39 prisoners set free under strict conditions was Daniel Ceballos, who had been detained for four years for promoting protests as mayor of the western city of San Cristóbal, according to Venezuela’s Supreme Court.

President Nicolás Maduro said after being re-elected in May in a contested victory that chief among his conciliatory measures would be releasing prisoners jailed for acts against the government.

Mr. Maduro said on state television on Friday that the freed prisoners had him to thank for going home, despite having been prosecuted for their crimes.