Scotland's landmark independence referendum has showed those in favour of keeping the 307-year union with England are on the edge of victory with most votes counted.