A band played Indian classical music on sitar, Indian flags festooned the square, and schoolchildren stood in the crowd to watch the ceremony as Mr Cameron and Indian finance minister Arun Jaitley unveiled the figure.
The Prime Minister said: “This statue is a magnificent tribute to one of the most towering figures in the history of world politics and by putting Mahatma Gandhi in this famous square we are giving him an eternal home in our country.
“Many of his teachings remain as potent today as when he first made them.
“’The best way to find yourself is to lose yourself in the service of others’ and ‘Be the change that you want to see in the world’ remain timeless, profound and inspiring words of wisdom.
“This statue celebrates the incredibly special friendship between the world’s oldest democracy and its largest, as well as the universal power of Gandhi’s message.”
The sculpture, created by Philip Jackson, was inspired by a 1931 photo of Gandhi at No 10 Downing Street, where he met the then prime minister Ramsay MacDonald.
The Prime Minister added: “On that same visit, he also went to see King George V.
“Arriving bare-chested in his dhoti, and marching ahead with his stick, he was asked if he felt under-dressed. He replied: ‘The King is dressed for both of us’.
“The man who turned the politically unimaginable into the politically inevitable; whose work in South Africa paved the way for Nelson Mandela; a man whose doctrine became the inspiration for the civil rights movement across the world.
“It was in London as a young man that Gandhi first learned to petition, to draft letters, to make speeches.
“It was here where he was treated fairly by his colleagues at the Inner Temple; that the foundations were laid for his battles against segregation and discrimination.
“And even years later, when he was striving for Indian independence, his respect for the people of this country shone through.
“If Gandhi could have lived anywhere in the world outside India, he said it would have been here in London. We should be proud of that and we should be proud of him.”
Mr Jaitley also gave a speech, and afterwards said he had met with Mr Cameron, the Chancellor George Osborne, and Leader of the Labour Party, Ed Miliband.
They were joined on stage by Gandhi’s grandson, the former governor of West Bengal, Shri Gopalkrishna Gandhi, who said his family was pleased at “the fact of his statue taking its place right beside that of his political descendent Nelson Mandela”.
He added: “How many countries celebrate the life work of a man who opposed it with vehemence for more than three decades? Not many.
“Britain does, and Britain celebrates Gandhi today because while oppose it he did, he opposed it in a cause that Britain now sees was just and in a way the world now sees was fair.”
Amitabh Bachchan, one of India’s most prominent actors, read from Gandhi’s work. A band played his favourite song, Raghupati Raghava Raja Ram, as the crowd sang along.
The statue was funded by the Gandhi Statue Memorial Trust, run by Lord and Lady Desai, who raised £1 million for the nine-foot bronze sculpture.
It stands opposite the statute of Sir Winston Churchill, who in 1931 described Gandhi as a “half-naked ... seditious fakir”.
Mr Jackson said after the ceremony: “Starting a sculpture is really like starting a book.
“I read everything I could about him, I looked at all the available images there are of him. I watched the famous Gandhi film - only once, because I didn’t want it to start looking like Ben Kingsley.
“One of the best things was meeting Gopalkrishna Gandhi, so I could get an insight into his character and the sort of man that he was. And that’s very important.
“It was considered by everyone that he was a man of the people, and therefore he should be kept at an accessible height.
“Somehow we manage to have acquired the best site in Parliament Square for the sculpture.
“He’s got the Supreme Court behind him, which is very appropriate, the Houses of Parliament in front of him. And he’s flanked by Nelson Mandela on one side, Abraham Lincoln behind him and Winston Churchill in front of him, so you can’t ask for more than that.”
Mr Jackson is known for statues of the Queen Mother and the Bomber Command memorial.
Secretary of State for Culture, Media and Sport, Sajid Javid, said: “This statue will stand as a reminder of Gandhi’s ideals and Britain’s historic relationship with India and its people.
“Our nations’ friendship as equals, which brings growth and prosperity to both our countries, owes much to Gandhi’s determination to achieve independence though peace.”