Judge Saliu Seidu, sitting at the federal high court in Lagos, said the apartment in the upmarket Ikoyi area of the city should be temporarily forfeited to the government, pending any challenge within 14 days.
Acting on a tip-off, agents from Economic and Financial Crimes Commission raided the property on 12 April this year and discovered just under $43.5m (£33.1m).
They also found £27,800 as well as 23.2m naira (£49,600), the court was told.
Documents established the flat was bought in 2015 by Folashade Oke, the wife of Ayodele Oke, who at the time was director general of the NIA.
It was alleged she bought the property using $1.66m from government funds to which her husband had access.
President Muhammadu Buhari was elected in 2015 on a promise to cut endemic corruption in government and has vowed to recover what he said were “mind-boggling” sums of stolen public money.
Oke, who had been suspended for keeping an unauthorised stash of cash in a private home, was sacked last week along with the country’s most senior civil servant, Babachir Lawal.
Lawal was accused of awarding deals for reconstruction in areas of north-east Nigeria hit by Boko Haram’s Islamist insurgency to companies in which he had a personal interest.
Buhari’s handling of the two cases has been seen as a litmus test for the extent of his anti-corruption drive, given that most of those arrested and charged so far have been high-profile members of the main opposition.
The Oke case was adjourned until 30 November.