hom·o·nym

homonym

a word that is pronounced and often spelled the same as another word, but has a different meaning. In the sentence, "She was mean to me, but she didn't mean it," the two instances of "mean" are homonyms.