The Virginia General Assembly agreed Thursday to a new bipartisan compromise on state legislative boundaries as Senate Democrats bowed to a gubernatorial veto of a redistricting proposal they adopted this month without Republican support.

The Senate’s map, the result of three days of sometimes-contentious negotiations between leading Democrats and Republicans, would result in districts that divide somewhat fewer communities than did the previous map, which Gov. Robert F. McDonnell vetoed April 15.

It would also make the state’s 40 Senate districts more competitive in elections, including this November’s.

McDonnell (R) said that the changes satisfied his concerns and that he would sign the bill into law.

“It is a great improvement over the previous plan that I vetoed,” McDonnell said in a statement.

Democrats said they think that the new proposal gives them the opportunity to retain their slim 22 to 18 Senate majority. “Each side wanted more, and we had to settle halfway,” said Senate Majority Leader Richard L. Saslaw (D-Fairfax). “They gave up some, we gave up some. That’s what it’s all about. . . . Both sides did okay.”

Legislative action was repeatedly delayed as negotiations slipped into Thursday evening as Republican senators negotiated among themselves over whether to support a plan hammered out by General Assembly leaders. In the end, lawmakers voted 32 to 5 to adopt the proposal, but Senate Minority Leader Thomas K. Norment Jr. (James City) said Republicans were hardly pleased with the results.

“I’m going to vote for this plan — not because I embrace it with any degree of affection,” he said.

The revised map brings the 140 districts of the state Senate and Republican-held House of Delegates into alignment with population shifts detailed in the 2010 Census. Northern Virginia would gain a new Senate seat and three new delegates under the proposal.

In the House, delegates voted 80 to 9 for a redrawn map of its 100 districts after making a handful of small changes from its original plan by unsplitting precincts in Norfolk and the Richmond area.

The Senate deal marked a remarkable turnaround for the chamber’s majority Democrats, who had belligerently pledged after McDonnell’s veto not to change a comma of their plan, daring the governor to reject the proposal again and toss a stalemated redistricting to the courts.

“The only thing he’s going to accept is absolute surrender on the part of the Democrats of the Senate of Virginia — and he’s not going to get it,” Saslaw said of McDonnell the day the veto was announced.

But senators became convinced that a court case could result in a map they would like less than one negotiated with Republicans. A plodding court case also would have left legislators in limbo, without established districts and unable to start campaigning for the November elections.

“One man’s cave-in is another man’s compromise,” said Sen. J. Chapman “Chap” Petersen (D-Fairfax).

Saslaw, known for his often-blunt demeanor, suggested that his uncompromising tone had partly been a negotiating tool to win the best deal. But he also said the public suggestion that Democrats would never make a deal had likely been unwise.

“It was probably one of my numerous inappropriate remarks,” he said.

Many legislators had assumed that McDonnell would not veto the map, because doing so required him to anger fellow Republicans by also rejecting a plan drawn by the GOP-led House of Delegates.

But McDonnell swept those concerns aside and vetoed both maps, indicating that he thought the Democrat-devised Senate plan may violate state and federal laws.

He also contrasted the Senate’s party line 22 to 18 vote on the map with the bipartisan support achieved in the House, which had adopted its redistricting plan on a 86 to 8 vote.

McDonnell said Attorney General Ken Cuccinelli II (R) has conducted a preliminary review of the compromise and thinks that it passes legal muster.

McDonnell’s veto seems to have had its desired effect, forcing Senate Democrats to renegotiate. The breakthrough came as Democrats agreed to shift a new district that had been drawn in the Richmond area to the west, which would benefit Republicans. In exchange, Republican senators agreed that the Hampton Roads area would lose a Senate seat because of population loss.

But the compromise map would retain two Republican seats in Virginia Beach instead of merging them, a Democratic proposal that had upset Republicans.

Instead it would place two Republicans in the Chesapeake area — Sen. Harry B. Blevins and Sen. Frederick M. Quayle — into the same district and merge the districts of the Roanoke-Lynchburg region’s Republican senators, Ralph K. Smith and Sen. Stephen D. Newman.

Prince William County would be represented by five senators instead of six, a change intended to satisfy complaints from county leaders that the area was being splintered.

And the new district drawn to accommodate Northern Virginia’s explosive growth would include more of Prince William and Loudoun County and no longer stretch west in Clarke County.

The three new House seats in Northern Virginia would include two seats largely centered in the growing counties of Loudoun and Prince William and one that includes another portion of Prince William and a part of Stafford.

The deal was driven by a quickly approaching deadline: The state must submit its plan to the U.S. Department of Justice in time for a 60-day review to ensure that the maps do not dilute the power of black voters and violate the 1965 Voting Rights Act.