Bayern said on their website (www.fcbayern.de) that an injury to Costa's left thigh had not healed and they had told the Brazilian football federation that the player could not be released.
"I greatly regret this," said Bayern chairman Karl-Heinz Rummenigge. "We all wanted Douglas to contest the Olympic Games in his home country, but the player’s health and fitness takes priority."
Bayern said Costa, who joined them a year ago from Ukrainian side Shakhtar Donetsk, would continue his sports rehabilitation programme in Munich.
The Olympic gold medal is the only major soccer title the five times world champions have never won.
News that makes sense
Your trusted source for staying up-to-date with the world around you. Get free daily news updates and analysis, straight to your inbox.
(Reporting by Alan Baldwin, editing by Rex Gowar)
