The home affairs minister said he was refused a visa as the constitution prohibits hate speech.
Mr Anderson runs the Faithful Word Baptist Church, which says that homosexuality is an abomination punishable by the death penalty.
He said that religious freedom no longer existed in South Africa.
"I feel sorry for people who live in South Africa, but thank God we still have a wide open door in Botswana," Mr Anderson posted on his Facebook page after the decision to refuse him a visa.
South Africa has one of the most liberal constitutions in the world which protects gay rights.
The BBC's Milton Nkosi in Johannesburg says Mr Anderson was invited by a local church to visit this month.
Two petitions with more than 60,000 signatures, organised by gay and human rights activists in South Africa, had called for the trip to be stopped.
"I have identified Steven Anderson as an undesirable person to travel to South Africa," Home Affairs Minister Malusi Gigaba said.
Mr Anderson's church is based in the US state of Arizona and describes itself as an "old-fashioned, independent, fundamental, King James Bible only, soul-winning Baptist church".
In a video posted on YouTube before South Africa's decision was made, he said that the trip was not going to be about homosexuality, but he stood by his views against homosexuality, which he said were endorsed by the Bible.

The heart of the design shows a group of soldiers lifting a comrade, with his outstretched arms hinting at the crucifixion.
The artist, Nicholas Mynheer, said this represents "an act of compassion and service to others".
The window will be dedicated at a service on 10 July.
Mr Mynheer said it was a privilege to produce a window for "such a splendid building as Southwell Minster" and to spend time in his life entirely dedicated to considering the Great War.
"It was to be a truly humbling experience as I started to get an inkling of the stupendous sacrifice by all involved," he said.
"Initially, I felt overwhelmed by the accounts of sheer horror - mind numbing cruelty - and yet ever so gradually, amidst the darkness, little glimmers of hope appeared; of one man helping another, love overcoming hatred, and it was this that I realised I had to depict in the design."
Southwell Minster is in Nottinghamshire, but it was the mother church of Derbyshire and Nottinghamshire at the time of the war.
Mr Mynheer said the sacrifice was not just made in the trenches and at the war front, so those at home are also reflected in the window.
Beneath the central group of soldiers a woman hangs up washing, blown by the gathering storm.
This represents the women and others who remained at home, but also Mary at the foot of the cross.

The Right Reverend Graham Tomlin said residents should be at the heart of the investigation, which is believed to have killed at least 80 people.
"If you keep... the people directly affected by it out of the inquiry process, it just takes an awful lot longer to get to the truth," he said.
Dr Tomlin, whose diocese includes the tower, said local trust was important.
His remarks were mirrored in his formal submission to the public consultation, which closed on Friday.
It is believed more than 300 submissions were made before the deadline.
Inquiry chairman Sir Martin Moore-Bick, a retired Court of Appeal judge, has already faced calls to resign from some residents of the west London tower block.
"It seems to me that the inquiry needs to get to the truth... but it also needs to win the confidence of the local people," Dr Tomlin told the BBC.
If it does not, he said, "whatever recommendations it makes is unlikely to get support."
He said the inquiry needs to not only look at the technical causes of the fire on the night in question, but also the issues faced by the community in the run-up to the tragedy.
"I want to see local people at the heart of the inquiry, not just on the outside," he said.
Residents' group Justice 4 Grenfell also made several submissions to the consultation process, including calling for investigation of the local council and a number of  government departments.
The fire in the 24-storey block started in a fridge freezer and destroyed 151 homes, both in the tower and surrounding areas.
Get news from the BBC in your inbox, each weekday morning
South Africa has barred controversial US pastor Steven Anderson from visiting the county because of his critical remarks about homosexuality.
[NEXT_CONCEPT]
A window commemorating the sacrifice of people from Nottinghamshire and Derbyshire in the First World War has been installed at Southwell Minster.
[NEXT_CONCEPT]
The Bishop of Kensington has called for locals to be closely involved in the Grenfell Tower fire inquiry.