Victoria Allen, 51, threatened to take Brannel School in St Austell, Cornwall to tribunal over the matter.
The dispute was settled out of court earlier.
She had told the pupil she did not agree with same sex relationships and she was unhappy that the rainbow emblem was used to represent gay pride.
More on the teacher row, plus more Devon and Cornwall news
Both parties spent the day behind closed doors at Bodmin Magistrates' Court thrashing out an agreement.
A joint statement said head teacher Andy Edmonds "recognised Victoria Allen's right to share her Christian beliefs with students and has apologised for any upset that Victoria Allen may have felt during the disciplinary process".
Outside the court, Mrs Allen said she was made to "feel like a criminal" for sharing her "personal, Biblical beliefs".
She said she believes the rainbow emblem, often used to represent the gay community, should indicate "God's promise not to flood the world again".
Mrs Allen said the student asked her a direct question about her personal religious beliefs.
"If a child asks my personal opinion I feel I should give it," she said.
In the statement, Mrs Allen acknowledged that staff "should share balanced views".
Libby Powell of the Christian Legal Centre, which supported Mrs Allens' claim, said: "Vicky was asked a question about her personal opinion.
"We know that there are lots of people who disagree with the Biblical view of marriage and they are free to disagree.
"What we want to say is that there has to be space for the other point of view, Vicky's point of view, to be there as well."
A school has apologised to a Christian teaching assistant it disciplined for sharing her views on gay relationships with a 14-year-old student.