Arsenal's Ozil, 29, was part of the Germany squad that exited the World Cup in Russia at the group stage and was the target of criticism for his performances as well as his meeting with Erdogan who has been accused of human rights abuses.
The Arsenal playmaker has Turkish ancestry and defended his actions in a lengthy statement, the first time he has publicly addressed the matter.
The past couple of weeks have given me time to reflect, and time to think over the events of the last few months. Consequently, I want to share my thoughts and feelings about what has happened. pic.twitter.com/WpWrlHxx74— Mesut Özil (@MesutOzil1088) 22 July 2018
"For me, having a picture with President Erdogan wasn't about politics or elections, it was about me respecting the highest office of my family's country," Ozil said in a statement on Twitter.
"My job is a football player and not a politician, and our meeting was not an endorsement of any policies.
"The treatment I have received from the DFB (German Football Association) and many others makes me no longer want to wear the German national team shirt," Ozil added.
"I feel unwanted and think what I have achieved since my international debut in 2009 has been forgotten.
"People with racially discriminative backgrounds should not be allowed to work in the largest football federation in the world that has players from dual-heritage families. Attitudes like theirs simply do not reflect the players they supposedly represent.
"It is with a heavy heart and after much consideration that because of recent events, I will no longer be playing for Germany at international level whilst I have this feeling of racism and disrespect," he added.
"I used to wear the German shirt with such pride and excitement, but now I don't."