Craig Walker took the seat on Fife Council with 2,539 votes, 896 more than Labour's Alan Seath (1,643).
The Tories polled 202 votes, UKIP 146 and the Lib Dems 61.
In another by-election SNP candidate Sarah King was elected in Armadale, Blackridge, Torphichen and Westfield in West Lothian.
She secured more than 43% of the vote.
Voter turnout was 30.7%.
Turnout in Glenrothes was 32.59%.
Labour councillor Betty Campbell, who had held the Fife Council seat since May 2007, died in January.
In the North East, the SNP also won a by-election in Buckie.
The SNP has won a council seat representing the Glenrothes West and Kinglassie ward in a by-election held after the death of a Labour councillor.