The 29-year-old was criticised after being photographed with Turkish president Recep Tayyip Erdogan at a London event in May.
He says he received hate mail and threats and was being blamed for Germany’s disappointing World Cup.
“I am German when we win, but I am an immigrant when we lose,” Ozil said.
German football chiefs have yet to respond to Ozil’s claims.
However Chancellor Angela Merkel “respects” his decision as he has done much for the national side, her spokesperson said on Monday.
The third-generation Turkish-German was born in Gelsenkirchen and was a key member of his country’s 2014 World Cup-winning side.
He has 92 caps and has been voted the national team’s player of the year five times since 2011 by fans.
However, the team failed to get beyond the group stages of the recent World Cup in Russia, despite being one of the favourites.
Ozil said his recent treatment made him “no longer want to wear the German national team shirt”.
In a lengthy statement posted on social media, he said he did not feel accepted in German society despite paying taxes, donating to good causes there, and being a World Cup winner.
Germany’s football association, the DFB, was among those to criticise Ozil after he had his photograph taken with Erdogan.
“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 while I have this feeling of racism and disrespect,” the player said.
“I used to wear the German shirt with such pride and excitement, but now I don’t. I feel unwanted and think that what I have achieved since my international debut in 2009 has been forgotten.”
Story courtesy BBC