The family of a Framingham grandfather accidentally killed in his home by a SWAT officer more than five years ago has settled their wrongful-death lawsuit against the town, court records show.

“This was a tragedy that will stain the town for­ever,” said Cheryl Tully Stoll, chairwoman of the Framingham Board of Selectmen, “but it was an accident. Our hearts will always be with the Stamps family.”

The dispute has lingered in the federal courts for four years. It was to go to trial Nov. 7 and had been scheduled for a status conference tomorrow.

Terms of the agreement were not immediately disclosed. However, U.S. District Court Judge F. Dennis Saylor IV noted in a one-page filing Friday that he had been advised by attorneys on the case “that this action has settled.”

Attorney Leonard H. Kesten, whose firm defended both the town and the officer, Paul Duncan, declined to discuss the settlement’s particulars yesterday, but said, “On behalf of the town, we’re pleased to close this chapter.”

Attempts to reach Eurie Stamps’ family or their lawyer were unsuccessful.

The estate sought to be awarded nearly $10 million when the civil action was filed in 2012.

Eurie Stamps Sr., a retired MBTA mechanic, was 68 on Jan. 5, 2011, when Duncan accidentally shot him in the head with a machine gun that had its safety off as Stamps lay face-down in a hallway during the execution of a search warrant by the Framingham Police ?Department’s SWAT team.

Before entering the home, police had arrested Stamps’ stepson on drug charges.

A panel of federal appellate justices ruled earlier this year that Stamps “was compliant and posed no threat to the officers,” and allowed the suit to proceed with its claim that Duncan had violated Stamps’ Fourth Amendment right against unreasonable search and seizure by pointing his loaded Colt M4 Commando machine gun at him.

Duncan was removed from SWAT duty, but cleared of criminal wrongdoing by the Middlesex District Attorney’s Office,?which found that his ?weapon had discharged as Duncan lost his balance while trying to handcuff ?Stamps.

“Mr. Stamps was not the target of the search warrant, was not suspected of any crime, did not resist the police, and posed no risk of danger to the police,” the complaint filed against the town stated.

The bullet struck Stamps in the face and exited through his heart.

“Mr. Stamps was unarmed, defenseless, made no furtive gestures or movements, complied with the officers’ demands, and did not attempt to flee or resist the police,” according to the complaint.

Stoll said the town’s SWAT team has been disbanded since Stamps’ death. A town commission also ?investigated the incident, she said, “and came back with the same verdict that it was a tragic accident.”