Vatican spokesman Father Federico Lombardi told Reuters that the visit to the mosque, which had been in the planning stages, has now been confirmed.
The visit, seen as another attempt at reconciliation by Benedict after he infuriated much of the Muslim world with comments taken as indicating he believed Islam was violent and irrational, will be his first to a mosque as Pope.
More than 25,000 people joined demonstrations Sunday against the pope's upcoming visit, police said.
The demonstration was the largest anti-pope protest so far ahead of Benedict's arrival Tuesday for a four-day visit, his first as pope to a predominantly Muslim country.
Some 4,000 police backed by riot trucks, armored vehicles and helicopters monitored the protest as the crowds grew.
Benedict XVI's predecessor, Pope John Paul II, made the first visit by a pontiff to a mosque during a trip to Damascus in 2001.
The Sultanahmet, or Blue Mosque, is the most famed in Turkey and a popular tourist attraction. It stands in a square of the same name in the historical district of Istanbul, opposite the Aya Sofya museum.
It was built early in the 17th century on the order of Sultan Ahmed I and is also near the Ottoman Topkapi Palace.