An appeals court has tossed out $172 million in damages awarded to Van Nuy’s MGA Entertainment in a trade-secrets lawsuit filed against Mattel Inc.

The two toy companies have been involved in an eight-year legal brawl over the Bratz doll franchise. MGA was accused by its El Segundo rival of stealing the Bratz design because Carter Bryant, the doll’s inventor, was working for Mattel in when he first conceived the dolls. A jury awarded Mattel $100 million in 2008, but the appeals court overturned that decision and ordered a new trial.

As part of the second trial, MGA countersued Mattel, accusing it of corporate espionage at toy fairs. It was awarded $172 million in damages by a jury in April 2011. However, the 9th Circuit Court of Appeals vacated the damages on the grounds that the jury never should have heard the case, since the countersuit was not sufficiently related to the original trial over the Bratz dolls.

“That both Mattel and MGA claimed they stole each other’s trade secrets isn’t enough to render MGA’s counterclaim compulsory,” Chief Judge Alex Kozinski wrote in the decision released Thursday. “What matters is not the legal theory but the facts.”

However, the appeals court upheld an award of $137 million given to MGA for its attorneys’ fees stemming from the long litigation with Mattel.

Mattel claimed victory in the court decision, noting it would not have to pay the $172 million in damages, but also indicated it was ready to end the litigation started by former Chief Executive Robert Eckert, who left the company in 2011.

“We look forward to the speedy and final resolution of this dispute,” it said in a statement.

However, MGA Chief Executive Isaac Larian stated he would pursue a new trial over his claims Mattel stole trade secrets from his company.

Mattel has already set aside funds to pay any costs related to the litigation. Its shares were down 89 cents, or about 2.3 percent, to $37.15 at the close of trading on the Nasdaq.