Clementina Cantoni seen in this video image after her release
She is said to be in good health and is expected to return home to Italy later on Friday.
Ms Cantoni, who works for Care International, was abducted by gunmen who forced her out of her car.
Interior Minister Ali Ahmad Jalali said that no concessions had been made to the kidnappers.
Ms Cantoni has been in Afghanistan since September 2003 and was in charge of a programme supporting more than 10,000 widows and their children.
Widows helped by her project staged demonstrations in the capital calling for her release.
We did not pay any ransom
Ali Ahmad Jalali
Afghan Interior Minister
And earlier on Thursday, hundreds of schoolgirls in the Afghan capital, Kabul, handed out nearly 3,000 stickers calling for Ms Cantoni to be freed.
Relief
Ms Cantoni was abducted in central Kabul on 16 May.
Announcing her release, an interior ministry spokesman said he was "happy to say that Clementina is well".
"She is in good health given the 24 day ordeal she went through," Lutfulla Mashal told reporters.
Her parents appeared on their apartment balcony after the news
He said the aid worker had spoken to her mother on the phone.
In his flat in Milan, Ms Cantoni's father appeared on the balcony to say: "My daughter, I greet you", Italian news agency Ansa reported. And in Luxembourg Italian Foreign Minister Gianfranco Fini said it was an "enormous relief".
Afghan officials had said a criminal gang was responsible rather than Islamic militants.
In a hastily arranged news conference, Minister Jalali said Ms Cantoni's release was "a result of the hard work of the police and the nation".
"The policy of the Afghan government is not to deal with the hostage-takers. We did not pay any ransom," he said.
The Afghan government had criticised the Italian embassy in Kabul for trying to negotiate Ms Cantoni's release with her kidnappers.
La cooperante italiana Clementina Cantoni, quien estaba secuestrada desde el pasado 16 de mayo, fue liberada en las últimas horas. La noticia ha sido confirmada por varias agencias noticiosas, así como por portavoces afganos e italianos.

Un portavoz afgano dijo estar ''"feliz de decir que Clementina está bien"'', mientras el primer ministro Ali Ahmad Jalali aseguró que no se hizo ninguna concesión o pago a los captores, si bien los italianos habían intentado negociaciones, acto criticado por el gobierno de Afganistán. Pasquale Terracciano, portavoz de la cancillería italiana, también ha confirmado la liberación.

Fabio Cantoni, padre de la cooperante, salió al balcón de la ventana de su casa en Milán. ''"Hija, te saludo"'', dijo sosteniendo el teléfono a los periodistas que se encontraban debajo de la ventana. ''"Gracias", agregó.

Cantoni, de 32 años, pertenece a la organización ''CARE International'', especializada en derecho internacional humanitario. En estos momentos se encuentra en Kabul.