House Republicans voted to proceed with a lawsuit against President Obama on Wednesday, saying that his executive actions are so extreme that they violate the Constitution.

The nearly party-line vote — all Democrats voted against it, and all but five Republicans voted for it — further agitated an already polarized climate on Capitol Hill as both parties used the pending suit to try to rally support ahead of the November elections.

Halfway across the continent, Obama almost gloated at the prospect of being sued.

“They’re going to sue me for taking executive actions to help people. So they’re mad I’m doing my job,” Obama said in an economics speech in Kansas City, Mo. “And by the way, I’ve told them I’d be happy to do it with you. The only reason I’m doing it on my own is because you’re not doing anything,” he said of Congress.

The clash came a day before Congress is scheduled to begin a 51 / 2 -week summer break and as must-pass bills on reshaping veterans’ health care and highway construction appeared headed for passage — while most everything else was not.

Speaker of the House John Boehner (R-Ohio), joined by Rep. Cathy McMorris Rodgers (R-Wash.), left, and incoming Majority Leader Rep. Kevin McCarthy (R-Calif.), right, speaks to reporters on Capitol Hill in Washington, D.C., on July 29, 2014. (J. Scott Applewhite/AP)

For instance, the House and Senate moved in dramatically different directions on legislation designed to deal with the flow of thousands of unaccompanied Central American minors arriving at the border.

Expecting a flurry of work once the elections are over in November, leaders in both parties have instead tried to position their rank-and-file to take advantage of the gridlock by blaming the other side. By the time this year concludes, the 113th Congress is all but assured of being the least productive in recorded history in terms of passing legislation signed into law.

The details of Speaker John A. Boehner’s lawsuit mattered little — it focuses on a narrow portion of the landmark health-care law — and instead each side focused on the larger symbolism of the moment.

Democrats linked the lawsuit to calls from outspoken conservative activists urging the impeachment of Obama, a battle cry that Democrats have amplified in an effort to raise money and get people to vote.

House Minority Leader Nancy Pelosi (D-Calif.), glaring at Republicans during the heated debate, accused Boehner (R-Ohio) of caving into “impeachment-hungry extremists.”

“Tell them impeachment is off the table. That’s what I had to do,” she said, noting several attempts by liberals to impeach President George W. Bush and Vice President Richard B. Cheney while she was House speaker.

Boehner, who has repeatedly said impeachment is not in the cards, connected the suit to a series of executive orders that Obama issued on climate change, immigration rules, the health-care law and raising the minimum wage for federal contractors, saying that those were power grabs that did not have requisite backing from Congress.

“Are you willing to let anyone tear apart what our founders built?” Boehner asked during debate.

The lawsuit is the culmination of heightened conflict since Obama took office in 2009, particularly since Boehner became speaker more than three years ago.

It is also unprecedented in its nature. Plenty of Congress members, in both parties, have filed lawsuits or briefs in support of suits against presidents. Generally, federal judges dismiss the cases because usually only those affected by the law had standing to file suit.

The novel idea for Thursday’s vote was driven by a clutch of conservative legal scholars who contend that the best way for Republicans to have legal standing in federal court is if the entire body passes legislation authorizing it.

Democrats predicted the courts would dismiss the suit, while mocking Republicans for their choice of focusing the fight on Obama’s decisions to delay certain mandates in the health law — a law that GOP lawmakers unanimously oppose and do not want to see implemented.

If the federal courts take up the matter, it could take years to reach conclusion and may have a larger impact on setting the parameters of the balance between the next president and Congress.

The short-term impact will be the political jockeying in the next three months. Democrats said the lawsuit would turn off middle-of-the-road voters who begin to make up their minds in the late summer and early fall, suggesting it would distract from the economic issues Republicans hope to focus on.

“They are limping into August, wrestling with themselves over impeachment, and being criticized for suing the president instead of addressing issues that matter to the middle class. This is not the August recess that they anticipated,” Rep. Steve Israel (N.Y.), chairman of the Democratic Congressional Campaign Committee, said in an interview.

In a four-day span after a top Obama adviser said he took the threat of impeachment seriously, the DCCC sent a flurry of fundraising pitches and brought in more than $2 million.

In the floor debate, the two sides clashed in the sharpest of terms.

Republicans defended the lawsuit as a way to protect Congress from executive overreach.

“I believe in this institution,” said Rep. Richard B. Nugent (R-Fla.). “I believe in the Constitution.”

Democrat after Democrat focused remarks on impeachment, which they said would be the logical outcome of a lawsuit asking the courts to say Obama had violated the Constitution.

Rep. Louise M. Slaughter (N.Y.), the ranking Democrat on the Rules Committee, called it a “monumental waste of time, energy and funds” that is designed only to encourage conservative voters to back Republicans this fall.

“This is a political maneuver timed to peak as Americans are going to the polls in November for the midterm elections,” Slaughter said. “This lawsuit is the drumbeat pushing members of the Republican Party to impeachment.”

In Kansas City, Obama did not bring up the hot topic of a possible impeachment proceeding. Instead, he showered attention on the lawsuit, relishing the opportunity to belittle the GOP.

“Stop being mad all the time. Stop just hatin’ all the time,” Obama said at the Uptown Theater. “Everyone sees this as a political stunt, but it’s worse than that because every vote they’re taking . . . means a vote they’re not taking to help people.”

Goldfarb reported from Kansas City. Ed O’Keefe contributed to this report.