The shooting came when loggers attacked police and forestry officials near the holy town of Tirupati, police said. Police are accused of excessive force.
Most of the suspected smugglers were from neighbouring Tamil Nadu state.
Sandalwood smuggling is rampant in southern India, with a tonne selling for tens of thousands of dollars on the international black market.
Red sandalwood or red sanders is a species of tree endemic to the Western Ghats of India.
The tree is prized for its rich red wood, mainly for making furniture, and is not to be confused with the highly aromatic sandalwood trees that are native to southern India.
Senior police official M Kantha Rao told the AFP news agency that policemen challenged a group of more than 100 smugglers who were cutting down trees in the remote forests near Tirupati early on Tuesday.
"Our police party warned them to hand over the logs. They were accompanied by forest officials as well. But the smugglers refused to hand over the logs," he said.
A forestry official said the woodcutters attacked the police with axes, sticks and stones in two separate areas of the state.
Police said 20 bodies had been recovered in the Seshachalam forest. Eight suspected smugglers were injured.
Most of those killed are believed to be Tamils and there was an angry reaction in Tamil Nadu to the killing.
Chief Minister O Pannerselvam demanded an investigation and the National Human Rights Commission said there had been a "serious violation" of human rights.
"Firing cannot be justified on the ground of self-defence since it resulted in the loss of lives of 20 persons," it said in a statement.
VS Krishna, general secretary of the Andhra Pradesh Human Rights Forum, said an earlier "gun battle" with loggers had turned out to be "one-sided firing" by police.
"They surrounded the workers deep in the forest, having every opportunity to take them into custody, but instead fired straight away, killing several of these workers," he told AFP news agency.
Correspondents say the loggers are often tribespeople or other poor migrant workers from Tamil Nadu.
India banned the sale of red sandalwood in 2000.
In 2004, police in Tamil Nadu shot dead one of India's most notorious sandalwood smugglers, known as Veerappan.
Police in India's Andhra Pradesh state say they have killed at least 20 suspected red sandalwood smugglers.