A tweet quoting Nelson Mandela by former US President Barack Obama has picked up more than 3 million likes on Twitter, breaking the record for most likes.

Posted on Sunday, the tweet reached the milestone on Thursday, breaking the previous record held by singer Ariana Grande after a bombing at one of her concerts in the English city of Manchester.

"No one is born hating another person because of the color of his skin or his background or his religion..." Obama wrote, quoting the late South African president.

A picture attached to the post shows Obama playing with toddlers of different racial backgrounds.

"No one is born hating another person because of the color of his skin or his background or his religion..." pic.twitter.com/InZ58zkoAm — Barack Obama (@BarackObama) August 13, 2017

The tweet, Obama's first in weeks, came in the context of deadly white supremacist violence in the town of Charlottesville, Virginia.

Heather Heyer, 32, was killed when a man drove a car into a crowd of anti-hate protesters on Saturday.

Police later arrested white supremacist James Fields Jr and charged him with second-degree murder, as well as other charges.

Obama has authored six of the top 10 most liked tweets in history.

His successor, US President Donald Trump, is a more prolific Twitter user but has yet to reach the Democrat's popularity on social media.

Trump's reaction to the violence in Charlottesville stood in stark contrast to Obama.

The 45th president of the US has repeatedly blamed both sides for the violence but also said there were "very fine" people on each side.