But they failed to retrieve it immediately from the seabed because it was stuck under debris from the main body of the plane, the ministry added.
"The navy divers in Jadayat state boat have succeeded in finding a very important instrument, the black box of AirAsia QZ8501," said Mr Tonny Budiono, a senior ministry official.
The recorders were at a depth of 30-32 metres [99-106 feet], he said in a statement.
Divers will on Monday try to shift the position of the wreckage to access the black box.
"However, if this effort fails, then the team will lift part of the main body using the same balloon technique used earlier to lift the tail," Mr Budiono added.
After a frustrating two-week search often hampered by bad weather, officials earlier Sunday raised hopes by reporting that strong ping signals had been detected by three vessels involved in the search.
Those signals were coming from the seabed less than one kilometre [0.6 miles] from where the tail of the plane was found, Malaysian Navy chief Abdul Aziz Jaafar said in a post on Twitter. Malaysia's Navy is helping in the search.
The Indonesian meteorological agency has said stormy weather likely caused the Airbus A320-200 to crash as it flew from the Indonesian city of Surabaya to Singapore on December 28.
But a definitive answer is impossible without the black box, which should contain the pilots' final words as well as various flight data.
Mr S.B. Supriyadi, a director with the National Search and Rescue Agency, told reporters earlier in the day that an object believed to be the plane's main body had also been detected near the source of the pings.
The search, which has involved US, Chinese and other international naval ships, has recovered 48 bodies so far.
Supriyadi said many bodies were believed trapped in the cabin, so reaching that part of the wreckage was also a top priority.
The tail of the plane, with its red AirAsia logo, was lifted out of the water on Saturday using giant balloons and a crane.
It was brought by tugboat on Sunday to a port near the search headquarters, at Pangkalan Bun town on Borneo island.
All but seven of those on board the flight were Indonesian.
The bodies of a South Korean couple were identified on Sunday, but their 11-month-old baby remains unaccounted for, Indonesian authorities said.
The other foreigners were one Singaporean, one Malaysian, one Briton and a Frenchman - co-pilot Remi Plesel. Their bodies have not been recovered.
While the cause of the crash is unknown, the disaster has once again placed Indonesia's chaotic aviation industry under scrutiny.
Indonesian officials have alleged Indonesia AirAsia did not have a licence to fly the route on the day of the crash, although the airline rejects the claim.
Indonesia's transport ministry quickly banned AirAsia from flying the Surabaya-Singapore route.
On Friday it suspended dozens more routes operated by five other domestic airlines for similar licence violations.