Smithfield Foods Inc. has agreed to pay $639,000 in fines and legal fees in a settlement with two environmental groups that sued over pollution of the Pagan River by the company's Gwaltney meatpacking plant in Smithfield, Va.

Aaron D. Trub, the company's vice president and secretary-treasurer, said Smithfield has agreed to pay $289,000 in fines, $300,000 in plantiffs' legal fees, $10,000 in interest to the U.S. Department of Justice, and $40,000 to the Virginia Institute of Marine Science.

The Chesapeake Bay Foundation and the Natural Resources Defense Council sued Smithfield in October 1983 under the federal Clean Water Act, which allows private citizens to sue companies for polluting. The groups alleged Smithfield dumped excessive amounts of chlorine and nitrogen into the Pagan River.

U.S. District Judge Robert R. Merhige found the company guilty of the dumping and fined it $1.2 million, a record under provisions of the Clean Water Act. Smithfield appealed the ruling and the fines to the U.S. Supreme Court.

The Supreme Court referred the matter back to the lower courts, which again levied the original fine, but the amount was reduced to $289,000 by the 4th U.S. Circuit Court of Appeals.