London Mayor Boris Johnson and UKIP leader Nigel Farage have been branded “racist” after alleging “part-Kenyan” Barack Obama dislikes Britain because of its history as a colonial power in Africa.

Johnson was likened to a right-wing Tea Party politician after his attack on Obama’s Brexit intervention seemed to get out of hand.

Writing in tabloid The Sun on the first day of Obama’s three-day visit to Britain, Johnson suggested the US president had an “ancestral dislike” of the British Empire because his father was from Kenya.

Kenya was formerly a British colony which achieved independence in 1963 after a bloody uprising.

Speaking to the Guardian, the UKIP leader said: “It’s just that you know people emerge from colonialism with different views of the British.

“Some thought that they were benign and really rather good, and others saw them as foreign invaders that kept people suppressed. Obama’s family come from that second school of thought and it hasn’t quite left him yet.”

Kenya endured a brutal conflict in the 1950s known as the Mau Mau Uprising, when a group of Kikuyu Kenyans sought to expel the British.

Some 12,000 Mau Mau rebels were killed during the uprising. Britain stands accused of perpetrating war crimes in the conflict, which dragged on for eight years and is believed to have contributed to Kenya’s eventual independence.