It also means the GCSB held the information at the time its agents briefed John Key on their involvement in the raid on February 29.
Mr Fletcher said the agency had relied on information supplied when it began surveillance "without checking further, and have apologised for that error".
The subsequent check in February led to the correct immigration status being supplied to the GCSB.
But the bureau has now claimed no one realised its spying was illegal until pointed out by Dotcom's lawyers months later.
Paul Davison, QC, drew the existence of the spies out after questioning the role of mysterious figures who met the FBI and the police.
The questions in court led the GCSB to seek protection from Bill English, who was acting Prime Minister when he signed a certificate in August which forced the court to keep its activities secret.
Mr Fletcher said: "In September, during court proceedings it was checked again."
The discovery the spying was illegal meant it was no longer a protected secret. "We alerted the Prime Minister on the 17th."
Meanwhile, the name of a senior figure at the GCSB has emerged.
Hugh Wolfensohn held pivotal roles during and after the bureau's spying operation, having oversight of operations, the legal office and the entire agency.
He has emerged as working at the bureau 16 years ago in Nicky Hager's book Secret Power as "CX" - the designation used to describe the agency's legal officer.
Mr Wolfensohn has used three titles at the agency in the past 12 months. Herald inquiries established he held the title of "operations director" since the GCSB and police were briefed about Megaupload in August.
Then, on December 19, Mr Wolfensohn assumed the role of "acting director", three days after the GCSB began spying on Mr Dotcom.
He held the position until January 29, when incoming director Ian Fletcher became the fifth person in just 18 months to lead the agency. Mr Wolfensohn was signing letters in May this year using the title "chief legal adviser".