Jason Blyth's Tear Up The Dark was picked up by Romanian pop star Teodora Dinu after being rejected as the UK's song for the 2017 contest.
Mr Blyth and his Kinross High pupils produced and recorded the backing track for the singer.
But the song failed to make the semi-final of the show to find the Romanian entry.
Mr Blyth, who watched the show on an internet stream, said the singer phoned him to commiserate shortly afterwards.
He told BBC Scotland: "She genuinely thought that with all the reviews we were getting in Romania we might be able to get to the semi-final.
"One of the other acts that didn't get through had been a favourite to win it and her song was written by the guy who won it last year."
Mr Blyth said the pupils were "genuinely gutted" at the result.
He said: "I had a queue at my door this morning waiting to hear what had happened, I felt really bad telling them.
"There were so many artists that are signed to major labels that we were up against."
The teacher said the school's song had been in a "David and Goliath" battle against the other entries.
He said: "All our music was recorded within the school, whereas a lot of people had spent thousands of pounds on production and promotion."
Romania returns to the competition this year after being expelled in 2016 due to its national broadcaster failing to pay outstanding debts dating back to 2007.
Mr Blyth will fly to Bucharest this week to meet Teodora Dinu to discuss future projects.
He said: "It's been an absolutely brilliant three or four weeks, it all happened so quickly with the song getting picked up by quite a well-known singer in Romania.
"The students were able to use some of this for their SQA coursework so that was great for them."
A song by a Scottish schoolteacher has missed out on the chance to become Romania's Eurovision entry.