Some 2,690 were in favour of staying within the NUS while 2,546 were against, with a record-breaking turnout of over 5,000.
However, the hard fought campaign was dogged by controversy, including allegations that:
Children "younger than five" were handing out leaflets on behalf of one campaign
Campaigners used Grindr, the gay dating app, to make slurs against opponents
Campaigners misinformed voters about the NUS' contribution to Exeter
Flats in halls were targeted by campaigners who made residents feel "uncomfortable"
The campus library's silent zone was invaded by noisy campaigners
The NUS contributed to the Stay campaign through use of its NUS Extra database, potentially contravening elections rules
The campaign for Exeter to disaffiliate adopted the moniker '#Exiter' and was until Thursday leading votes, according to live tallies.
However that lead was overturned and the Stay campaign to remain in the NUS won by a margin of 5.6%.
The win is a boost for the national union after Lincoln University and Newcastle students cut ties with the NUS this week.
Yet despite the clear result, the campaign was marred by allegations of dirty tricks.
Claims made on anonymous messaging app YikYak said that campaigners were visiting flats unannounced and persuading students to vote to stay in the NUS.
And further dubious tactics were alleged by a leading Exiter campaigner.
However, an Exeter Students' Guild spokesman said on Friday: "We have had no student complaints around harassment and intimidation."
Stay campaigners spoke of widespread misinformation perpetuated on both social media and on campus.
Students’ Guild President, and leader of the Stay Campaign, Laura-Jane Tiley told The Huffington Post UK on Thursday: "We've spent so much time countering the false claims made about our NUS membership.
"We benefit hugely from being a part of NUS and the returns to students far outweigh our affiliation fee."
We firmly believe that the interests of Exeter Students are best served by being part of the NUS Laura-Jane Tiley, students' guild president and leader of Stay in NUS campaign
Celebrating the result, Tiley said in a statement on Friday: “We firmly believe that the interests of Exeter Students are best served by being part of the NUS. Like the leave campaign we do believe that the NUS needs to change, but that the best way of doing this is to remain a part of the organisation.”
We are of course enormously disappointed Steve Hawkins, leader of Exiter to leave NUS campaign
Steve Hawkins, leader of the Exiter campaign and third year Philosophy and Social Economy student said: “We are of course enormously disappointed with this result. With more than 2,000 students voting to leave NUS, it is absolutely clear that huge swathes of students are fed up with the organisation and the way it is operating."
Students at the University of Surrey also voted to Stay in the NUS on Thursday.
Exeter's referendum was called well before controversy was stoked at the union's national conference.
It comes as Newcastle University students joined Lincoln in voting to disaffiliate from the NUS this week.
Newcastle's vote saw a landslide victory for those campaigning for disaffiliation, with some 67 percent in favour of disaffiliation, though with lower turnout than Exeter.
Dominic Fearon, Newcastle Student Union president, said it was clear students felt the NUS “no longer represents their views, does not prioritise correctly, and is not effective at achieving change."
Richard Brooks, NUS vice-president, union development, expressed delight at the result at Exeter, but said that a full package of reforms will be heard at next year's national conference.
He said: "I'm so proud and delighted that students at the University of Exeter have voted for their guild to remain affiliated to our national union so we can continue to fight for students' rights.
"When I attended the debate in Exeter students raised concerns and I want to be clear we are doing our best to answer these. I and the officer team at NUS look forward to working with Exeter Guild as we improve and reform."