Ozil, 29, was part of the Germany squad at the World Cup in Russia and was fiercely criticised as they crashed out at the group stage.
A photograph he posed for with Turkey’s president Recep Tayyip Erdogan ahead of the tournament led to his loyalty to Joachim Low’s side being questioned.
Germany team boss Oliver Bierhoff suggested Ozil should have been dropped after his failure to clear up the Erdogan meeting.
Ozil, who is of mixed German and Turkish heritage, defended his actions in a lengthy statement issued through his social media accounts on Sunday, the first time he has publicly addressed the matter, saying he and his family had received hate mail, threatening phone calls and social media abuse.
“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,” he said in his statement.
“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.
“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.
“I used to wear the German shirt with such pride and excitement, but now I don’t. The decision has been extremely difficult to make because I have always given everything for my teammates, the coaching staff and the good people of Germany.
“When high-ranking DFB officials treat me as they did, disrespect my Turkish roots and selfishly turn me into political propaganda, then enough is enough. That is not why I play football, and I will not sit back and do nothing about it. Racism should never, ever be accepted.”
Ozil blamed the German Football Federation (DFB) for failing to defend him against his most strident critics and singled out mistreatment from DFB president Richard Grindel as the most frustrating issue.
“Arguably the issue that has frustrated me the most over the past couple of months has been the mistreatment from the DFB, and in particular the DFB President Richard Grindel,” he said.
“Whilst I attempted to explain to Grindel my heritage, ancestry and therefore reasoning behind the photo, he was far more interested in speaking about his own political views and belittling my opinion.
“I will no longer stand for being a scapegoat for his [Grindel’s] incompetence and inability to do his job properly.”
Turkish ministers on Monday applauded the decision.
“I congratulate Mesut Ozil who by leaving the national team, he has scored the most beautiful goal against the virus of fascism,” Justice Minister Abdulhamit Gul wrote on Twitter.
Turkey’s Sports Minister Mehmet Kasapoglu added: “We sincerely support the honourable stance that our brother Mesut Ozil has taken”.
Ozil was a member of the Germany side that won the World Cup in 2014 and has been voted Germany’s national team player of the year on five separate occasions.