RIO DE JANEIRO — Brazil’s attorney general on Friday charged Congressman Jair Bolsonaro, a far-right presidential candidate who has been running in second place in the polls, with inciting hatred and discrimination against blacks, indigenous communities, women and gays.

The case injected a new jolt of drama into Brazil’s presidential election, which will be held in October. The charge came less than a week after the front-runner in the race, former President Luiz Inácio Lula da Silva, began serving a 12-year sentence for corruption.

The charging document, which was signed by Attorney General Raquel Dodge, includes a long list of incendiary remarks by Mr. Bolsonaro, who has developed a strong and loyal following by using harsh language and vowing to adopt severe tactics to address Brazil’s epidemic of violence.

If convicted, Mr. Bolsonaro, 63, could face up to three years in prison and a $117,000 fine.

Ms. Dodge outlined several passages from a speech Mr. Bolsonaro gave a year ago in Rio de Janeiro, alleging that they constituted “hate speech.” Mr. Bolsonaro lamented the state of quilombolas, traditional communities of Afro-Brazilians that enjoy legal protections.