Gunmen killed 20 people and injured seven others in a series of mass shootings in Brazilian city of Sao Paulo on Thursday night, officials said.

Sao Paulo's secretary of public security Alexandre de Moraes said the attacks occurred just before midnight at 12 different locations in the municipal areas of Osasco, Barueri and Itapevi and were largest massacre of the year, according to Xinhua.

Seventeen people were killed in Osasco municipal area, 24 kilometres from Sao Paulo, and two killed in Barueri locality due to an unknown gunmen, reported Press Latina.

The masked gunmen pulled up in a car before shooting people, witnesses said.

"I've never seen so many people killed overnight in Sao Paulo," a forensic expert told local newspaper, according to BBC.

Brazilian authorities are investigating the possibility that shootings were targeted killings. Investigators are also working on hypothesis that killings could be revenge attacks by corrupt police officers.

"When we get to the suspects, whether they are police or not, we'll act quickly to detain them," Moraes told reporters, according to New York Times.

Osasco municipal mayor Jorge Lapa told local media he believes the killings could be linked to deaths of two cops last week, according to Anadolu Agency.

"We will investigate if the killings were committed by drug traffickers, by off-duty police officers or were acts of vengeance for the recent killings of two police officers," said Moraes, according to Associated Press.

Amnesty International's Brazil head Atila Roque demanded a swift and impartial investigation to find perpetrator of crime.

 "Off- and on-duty policemen are frequently responsible for a significant portion of these homicides. A swift, impartial and transparent investigation must be conducted to discover who is responsible for this barbaric act," Roque said in a statement, according to Associated Press.