European election: David Coburn becomes Ukip's first Scottish MEP
Nigel Farage's party picked up 10.4% of the vote, giving them the sixth and final seat available north of the border.
Ukip has won its first parliamentary seat in Scotland after a knife-edge European election contest.
Nigel Farage's party, which dominated in England, picked up 10.4% of the vote, giving them the sixth and final seat available north of the border.
The result was delayed until Monday to allow for counting in the Western Isles.
It caps a remarkable European election for Ukip, which saw it stretch ahead of Labour and the Conservatives with the highest share of the vote across Britain as a whole.
In Scotland, the SNP and Labour remain on two seats each while the Tories keep their single seat.
The Lib Dems were beaten behind the Greens and lost their only seat in a dreadful UK-wide result for Nick Clegg's party.
The complicated proportional voting system meant that the SNP had to extend its share of the vote beyond one-third of the total in Scotland if it had any chance of keeping Ukip out.
But Alex Salmond's party fell just short with 389,503 votes - a 28.9% share.
The Green Party had also hoped to pick up its first seat and block Ukip, but ended with 108,305 votes (8%).
Labour saw its vote increase by five points to 25.9% with 348,219 votes, keeping its two MEPs, while the Conservatives held on to their single seat with 231,330 votes (17.2%).
The Liberal Democrats won just 95,319 votes (7.1%) and lost their only MEP in Scotland while being beaten to sixth place behind the Greens.
Turnout in Scotland was just 33.5% - which is still an improvement on 2009 when only about 28.5% of the electorate voted.
Across Scotland, turnout peaked at 43.1% in East Renfrewshire and 41.6% in Edinburgh. It was lowest in North Lanarkshire at 28.1%.
Ukip's winning candidate, David Coburn, said: "The Ukip revolution has now come to Scotland. I will do my best to make sure I highlight the problems of the European Union. When I'm in Brussels I will do my best to make sure Scottish business and Scottish people know the daft schemes they're cooking up there to make our lives infinitely more awkward.
"My second mission will be to make myself redundant. I want to get out of the European Union at the first available opportunity, and that I will do.
"On the bigger picture, Ukip has done well on the British stage as a whole and the fact that we're winning in Scotland and got such a good score in Scotland - getting up to 14% in some areas - is something we're very proud of."
Mr Coburn said he will fight hard against the campaign for Scottish independence. He pledged to ensure every Scottish soldier serving abroad gets a vote in the referendum.
Of the six winners, only Mr Coburn does not live in Scotland. His address was declared as being in Kensington, London.
Ian Hudghton, re-elected for the SNP, said his party won overall.
"We also have the opportunity in September to ensure that we transform our experience as members of the European Parliament, and as a country in the European Union, by voting 'yes' and becoming a normal independent member state with the right to representation as a nation, as a government, as well," he said.
Scottish Conservative MEP Dr Ian Duncan, 41, said: "I am delighted the people of Scotland have placed their trust in me and I intend to repay that trust when I get to Brussels.
"I was only 16-years-old the last time the Scottish Conservatives got a higher number of votes in the European elections. Struan Stevenson is a tough act to follow but I am looking forward to building on his excellent work, particularly in getting a better deal for fishermen. This is a very exciting time in the history of our position in Europe and we have an opportunity to secure real change to our relationship with the EU.
"The people of Scotland clearly want change and I will go to Brussels determined to fight for their interests. From fishermen in the Shetland Islands and farmers in Dumfries, to those working in the financial sector in Edinburgh, my role is to represent everyone. A Europe that works for us not against us is my aim and I will continue to listen to the people of Scotland to ensure that it is their interests, their concerns and their desires that I am championing in Brussels."
Returning Labour MEP David Martin said SNP leader Alex Salmond has allowed Ukip in by polarising the debate in Scotland.
"I'd like to suggest to David Coburn that the first thing he does when he sits down and recovers from the champagne is write a letter to Alex Salmond because there is no doubt in my mind that Alex Salmond's decision to polarise the campaign, the Scottish debate, between two extremes is why David Coburn is with us today as a member of the European Parliament," he said.
The Scottish independence referendum will be held on September 18.
An analysis of the European votes suggests the pro-independence parties, SNP and Green, secured about 37% of the vote, on a low turnout across Scotland.
Mr Coburn was interviewed by Scotland Tonight's Rona Dougall in April