About 100 protesters gathered at the Canon's Gait pub on the Royal Mile in Edinburgh, where Farage had scheduled a news conference, The Scotsman reported.
They carried a banner with the message "Vote Yes for Scotland" and hurled abuse at Farage, calling him homophobic. Some protesters chanted: "You're a racist. Go home to England."
Some in the group got into the pub, where Farage was explaining UKIP's program to reporters while drinking real ale. After they were ejected and the doors locked, protesters chanted "scum, scum" outside.
Farage had come to Scotland to support Otto Inglis, UKIP's Scottish secretary and a candidate in a parliamentary by-election in Aberdeen.
The crowd foiled two attempts by Farage to get away in taxis. Police eventually got him into a van.
UKIP supports withdrawal from the European Union and limits on immigration. Farage denies the party is racist. Farage said he opposes Scottish independence, although he believes further devolution is inevitable.
After his escape, Farage sent out a tweet: "Am okay after the Edinburgh fracas, but if that is the face of Scottish nationalism then it is pretty ugly."