Mr Anwar, a criminal defence solicitor, received almost 4,500 votes from students.
The only female nominee, Lady Hazel Cosgrove, received the second highest number of votes at 1,400.
Mr Anwar will take over from intelligence whistleblower Edward Snowden who has served three years in the role.
Sir Vince Cable came third on 535 votes, with right-wing journalist Milo Yiannopoulos fourth on 533.
"It's a tremendous result - a landslide victory", Mr Anwar said.
"For me, it just encompasses the fact that students at Glasgow University do care.
"They've sent a message of unity against hatred and bigotry. They want their voices to be heard - they've fought for far too long and have been ignored."
He added: "They've entrusted me to be an active, working rector.
"I intend to keep all my pledges in the manifesto to fight for students, all students, to fight for the issue of mental health, to fight over rocketing rents, to fight over the issue of Brexit and to ensure that no student should suffer in silence at this university and that they get the backing and funding and support of everyone at this campus."
First Minister Nicola Sturgeon offered her congratulations to Mr Anwar on Twitter.
Human rights lawyer Aamer Anwar has been elected as the new rector of the University of Glasgow.