In Ayr, Siobhian Brown defeated the incumbent John Scott, who had held the seat since 2000, by 18,881 votes to 18,711.
Ms Brown reversed a majority of just 750 votes, winning by 170.
Scottish Labour won 4,766 votes in the seat, while the Liberal Democrats took just 808, with a turnout of 68 per cent of the electorate.
Earlier on Friday, Paul McLennan won 17,968 votes in the East Lothian seat, which was held by former Labour leader Iain Gray until his retirement this year.
Mr Gray boasted a majority of 1,127, but after a 2.58 per cent swing that has now shifted to a 1,179-vote lead for the SNP.
Scottish Labour candidate Martin Whitfield won 16,789 votes with a turnout of 69 per cent.
In the last parliamentary term, the SNP held 63 seats, just two shy of an overall majority.
The Scottish Tories won 9,470 votes in East Lothian, while the Liberal Democrats took 1,556.