WASHINGTON — He lived out of his van in the Northern Virginia suburbs and took showers at the Y.M.C.A. On Facebook, he posted furious criticism of President Trump and pledged allegiance to Senator Bernie Sanders of Vermont. Back home in Illinois, neighbors complained to the police of his practicing his shooting near their home.
Shortly after 7 a.m. on Wednesday, the police say, James T. Hodgkinson, 66, of Belleville, Ill., opened fire on a baseball field in Alexandria, Va., just steps from the Y.M.C.A., spraying bullets at members of the Republican congressional team practicing there.
Four people were shot in the assault, including Representative Steve Scalise of Louisiana, the majority whip and third-ranking Republican in the House. An ensuing firefight with the police took Mr. Hodgkinson’s life.
The suspect’s brother said Mr. Hodgkinson was a critic of Mr. Trump, upset over last fall’s election and intent on bringing his protest to Washington. But his more immediate motive for the attack remained unclear late Wednesday, even as investigators surrounded Mr. Hodgkinson’s home on the outskirts of Belleville, a town of 40,000 across the Mississippi River from St. Louis.
“I know he wasn’t happy with the way things were going, the election results and stuff,” his brother, Michael Hodgkinson, said in a phone interview after he received the news on Wednesday.
“Totally out of the blue,” he added, saying that his brother was engaged in politics but otherwise led a normal life.
Conversations on Wednesday with friends and family, a review of police records and an examination of Mr. Hodgkinson’s voluminous writing on Facebook offered some clues. He was deeply invested in liberal politics and had volunteered for Mr. Sanders’s presidential campaign. He also had run-ins with law enforcement over the years.
In 1996, tragedy struck when his 17-year-old foster daughter committed suicide by dousing herself with gasoline and setting herself on fire in a car, according to The Belleville News-Democrat.
The newspaper reported that the daughter had been living with the Hodgkinson family for months and had tried to kill herself before.
“He seemed like a loner,” said William D. Euille, Alexandria’s mayor from 2003 to 2016, who came to know Mr. Hodgkinson during regular morning stops at the Y.M.C.A. “But very nice.”
For much of his adult life, Mr. Hodgkinson lived about 100 yards off a rural road in a two-story home on the outskirts of Belleville. He was a high school wrestler, worked for years in construction and then shifted to the home inspection business, starting his own company, JTH Inspections.
Charlene Brennan, a real estate agent in Belleville, said Mr. Hodgkinson had conducted inspections for housing sales she worked on over the years.
“He did not come off as a radical,” Ms. Brennan said. “He did not come off as an unstable individual. He wasn’t belligerent. He was just kind of a normal guy.”
On social media accounts and in frequent letters to The Belleville News-Democrat, though, Mr. Hodgkinson showed a political intensity. He appeared to have taken Mr. Trump’s victory in November particularly hard, letting a license on his home inspection business lapse that month. And in late March, the authorities said, he relocated to Alexandria, just south of Washington.
Throughout, Mr. Hodgkinson continued to post blistering Facebook assessments of Mr. Trump and the Republicans in charge in Washington.
On Tuesday morning, he posted a cartoon: “How does a bill work?” “That’s an easy one, Billy,” the cartoon reads. “Corporations write the bill and then bribe congress until it becomes law.”
“That’s Exactly How It Works. …” Mr. Hodgkinson wrote.
The page was filled with references to Mr. Sanders, who has called on Democrats to endorse more progressive politics since losing the Democratic nomination to Hillary Clinton last year.
In a statement on Wednesday, Mr. Sanders condemned violence of any type. “I am sickened by this despicable act,” he wrote. “Let me be as clear as I can be. Violence of any kind is unacceptable in our society and I condemn this action in the strongest possible terms.”
Mr. Hodgkinson’s behavior got the attention of local authorities several times over the years, records from the St. Clair County Sheriff’s Department show.
In April 2006, Mr. Hodgkinson, according to the sheriff’s department, forced his way into a neighbor’s home to find his daughter, grabbed her by the hair and in an ensuing exchange punched his daughter’s friend in the face.
Later, when the boyfriend of the daughter’s friend confronted Mr. Hodgkinson at home, the boyfriend told the sheriff’s department that Mr. Hodgkinson had answered the door with a shotgun aimed at his face and struck him with it.
Mr. Hodgkinson was charged with domestic battery, aggravated discharge of a firearm and criminal damage to a motor vehicle. The charges were later dismissed.
Friends and acquaintances said they were stunned by Wednesday’s shooting. Dale Walsh, who identified himself as a friend who knew him as Tommy, said Mr. Hodgkinson had been a vibrant presence when he was younger.
“He wasn’t evil,” he said. “I guess he was tired of the politics.”
In Alexandria, Mr. Hodgkinson could be found most mornings at the Y.M.C.A., Mr. Euille said. The two men made small talk about politics and old movies, Mr. Euille said, and Mr. Hodgkinson asked about finding work in town and good places to eat. Most days, Mr. Euille said, Mr. Hodgkinson would sit — often for hours — in a small reception area on his laptop.
That was the case Tuesday morning as well, Mr. Euille said. At some point, Michael Hodgkinson said, his brother called home to tell his wife that he missed her and their dogs and would be coming home.
Twenty-four hours later, Mr. Hodgkinson unleashed his attack just a few paces from the gym’s front door, on the well-groomed baseball diamond where the congressmen were practicing.