Updated

By Jonathan Stempel

NEW YORK (Reuters) - A federal judge on Wednesday said the U.S. Securities and Exchange Commission improperly withheld documents from the Dallas Mavericks' billionaire owner Mark Cuban, who is defending against insider trading charges.

The ruling by U.S. District Judge Reggie Walton in Washington, D.C. came a day after a federal appeals court reinstated the SEC's civil fraud case against Cuban over his 2004 sale of stock in Internet search company Mamma.com.

Walton said he could not conclude the SEC made a "good faith effort" to search for records that Cuban had requested under the federal Freedom of Information Act.

He also rejected the SEC request for three years to respond to Cuban, calling it an "extraordinarily long period of time."

The judge scheduled an October 22 hearing to set a timetable to release documents, and determine whether the SEC could withhold documents that might reveal investigative strategies.

Cuban, 52, had sued the SEC in May 2009, six months after the agency filed its insider trading case against him.

He sought a variety of documents related to Mamma.com, now known as Copernic Inc, as well as other businesses he ran or once ran, including the Mavericks, television channel HDNet, Landmark Theatres and Broadcast.com Inc. Cuban is worth $2.4 billion, Forbes magazine said in March.

"We would describe the ruling as a complete victory," said Lyle Roberts, a partner at Dewey & LeBoeuf LLP representing Cuban. "The judge was sharply critical of the SEC's efforts."

SEC spokesman John Nester declined to provide immediate comment, having yet to review Walton's ruling.

The SEC had cited a variety of reasons for withholding various documents, including a need to keep internal deliberations private, attorney-client privilege, and the privacy rights of individuals named in the documents.

In its insider trading lawsuit, the SEC accused Cuban of selling his 6.3 percent stake in Mamma.com in June 2004 after learning the Montreal-based search engine company was planning a stock offering that could dilute his stake. It said Cuban's sale allowed him to avoid more than $750,000 of losses.

Tuesday's decision by the Fifth Circuit Court of Appeals to reinstate that lawsuit paves the way for a possible trial.

The FOIA case is Cuban v. SEC, U.S. District Court, District of Columbia, No. 09-00996.

(Reporting by Jonathan Stempel in New York; Editing by Richard Chang)