The 35-year-old is his country's most-capped player, with 180 appearances for Spain since making his debut in March 2005.
Sources told ESPN that people close to Ramos had feared the news since last week.
"After a tough few months and a strange season unlike anything I have experienced in my career comes the Euros," Ramos wrote on Twitter on Monday.
"I have fought and worked every day, in body and soul, to be able to reach 100% for Real Madrid and the national team but things don't always work out the way we'd like. It pains me not to have been able to help my team more and not to play for Spain but, in this case, the best thing to do is rest, fully recover and come back next year like we've always done.
"It hurts not to represent your country, but I have to be honest and sincere. I wish all my teammates the very best of luck and I hope we have a great Euros. I'll be another fan cheering on from home. A big shout to everyone and #VivaEspaña and #HalaMadrid always!"
The centre-back was injured on his last international appearance when he came on as an 86th-minute substitute in Spain's 3-1 World Cup qualifying victory over Kosovo in Seville on March 31.
Enrique faced criticism for that decision, with a perception that Ramos has been prioritising breaking the men's international appearance record of 184 caps held by Egypt's Ahmed Hassan.
"He hasn't been able to compete during this season, especially since January, in the right conditions," Enrique said in a news conference on Monday.
"Not just compete, but even train with his teammates. It wasn't easy. Yesterday evening I told him. We had a telephone conversation. It was difficult, I understand it -- I feel bad because he has always been very professional.
"It's a complicated decision, but I always look for what's best for the team and the group. I recommended that he be selfish, think about himself and recover 100%, to regain his level and to keep playing for his club and the national team in the future."
The calf muscle problem Ramos picked up against Kosovo saw him miss a series of key games, including both legs of Madrid's Champions League quarterfinal with Liverpool and the first leg of their semifinal with Chelsea, returning for their 2-0 second-leg defeat at Stamford Bridge.
He had also been absent from January until March after undergoing surgery on the meniscus of his right knee.
The injuries have come at the worst possible time for Ramos, who has been unable to demonstrate on the pitch that he deserves an improved contract offer from Madrid.
"Whatever decision I take with Sergio Ramos generates controversy," Enrique added. "When I pick him for 90 minutes, because he's played a lot of minutes and hasn't rested.
"When I pick him for 5 minutes, that's bad, to get another cap. I know where I am and what it means to be a top level coach, with so much exposure to media noise. I accept it. I hope it doesn't affect the national team."
The club captain's deal expires at the end of June and no agreement has been reached on an extension.