The man suspected of killing 18 people and injuring 13 others at a bar and a bowling alley in Lewiston, Maine, on Wednesday night was found dead of an apparent self-inflicted gunshot wound on Friday, officials said, ending a sweeping manhunt that had forced thousands of residents throughout the region to remain in their homes.

The body of the man, Robert R. Card II, 40, was found at a recycling center where he used to work, according to authorities briefed on the matter. The owner of Maine Recycling, Leo Madden, confirmed in an interview that the suspect had worked at the company, which is in Lisbon Falls, a little more than 10 miles southeast of Lewiston.

Commissioner Michael J. Sauschuck of the Maine Department of Public Safety said the body was found at 7:45 p.m. but did not specify when officials think the suspect died.

The hunt for Mr. Card had extended across much of a largely rural state with many potential hiding places, producing an atmosphere of high anxiety as helicopters whirred over farms and forests, police cruisers roared along rural roads and divers plunged into the chilly waters of the Androscoggin River.