MEXICO CITY — The Cuban government announced Friday that it would release 3,522 prisoners from its jails before the pope’s visit this month, a gesture the nation also took before the last papal visit, in 2011.

The authorities will pardon a mix of women, inmates younger than 20 with no prior offenses, those older than 60, prisoners with illnesses, some foreigners whose countries have agreed to repatriate them and others whose terms are coming to an end. But they will not free those charged with serious crimes like murder or child sexual abuse or crimes against national security, which often means they are political prisoners.

The Cuban government has twice before released prisoners preceding a papal visit, measures meant to elicit good will for the state.

Now, however, ahead of the visit of a popular pope and in the wake of warming diplomatic ties with the United States, the move is sure to garner more attention than in the past. Pope Francis will be visiting Cuba from Sept. 19 to Sept. 22.