"I did what every Muslim has to do. God willing, the pope will not come to Turkey, but if he does, he will see what will happen to him," Ibrahim Ak, 26, told the DHA news agency while he was being taken by the police on Thursday.
Antonino Maggiore, the Italian embassy spokesman in Ankara, said a security guard at the consulate had heard the man say something about his Muslim identity.
US broadcaster CNN Turk said the attacker threw his weapon into the consulate grounds before he was detained.
Benedict's first visit to predominantly Muslim Turkey from November 28 to December 1, has been overshadowed by Muslim anger since a lecture he gave in September at a German university in which he quoted a 14th-century Byzantine emperor in a passage seen as critical of the Prophet Muhammad.
"We think that this is something that is an isolated incident and does not disturb the overall calm preparations for the trip," chief Vatican spokesman Father Federico Lombardi said.
The leader of more than one billion Catholics has several times expressed regret over the reaction to his speech, but has stopped short of the unequivocal apology wanted by some Muslims.
"If an opportunity arises for Erdogan to meet the pope during his visit, he will do so, but at the moment that looks very difficult given the busy schedule"
A Turkish government official
Some of the strongest criticism of the speech came from Turkey, where nationalists and Islamic activists have pushed for his trip to be cancelled.
Recep Tayyip Erdogan, Turkey's prime minister, has decided not to meet the pope, a move that Italian commentators said amounted to a diplomatic snub.
"If an opportunity arises for Erdogan to meet the pope during his visit, he will do so, but at the moment that looks very difficult given the busy schedule," a Turkish government official told Reuters.
Many Turks remain uneasy about the pope's trip, some fearing that it will increase the popularity of non-Muslim religions or threaten the country's secularism.