In the end, the two sides spent about the same amount. But the effort may take a greater toll on the Democrats, who - in their defense of what was once considered the safest of safe seats - were forced to exhaust funds they expected to use this fall to defend vulnerable incumbents in a harsh political environment.

The Republican insurgent outspent Coakley, roughly $8.7 million to $5.1 million during the six weeks following the primaries, according to estimates provided by the campaigns. Coakley also received help from the national and state Democratic Party committees, who spent about $4.3 million, mostly on advertising and all of it in the last week, to prop up her wilting candidacy. Their GOP counterparts did not pay for any ads to help Brown. Outside interest groups also played a major role, with seven organizations spending nearly $2.7 million to help Brown, and five others spending more than $1.8 million on Coakley’s behalf.

Brown raised so much late money - about $1 million a day via the Internet at the end - that he couldn’t spend it all. He ended the campaign with an estimated $4 million in his campaign account, spokesman Eric Fehrnstrom said. The campaign’s original budget was $1.2 million, but it ultimately raised about $13 million. With a flush campaign account, Brown will enter office in a stronger position to defend against an almost certain challenge in 2012.

The money allowed the campaigns and their allies to target voters with a relentless assault of political messaging, from the barrage of “robo calls’’ on their voice mail, text messages on their cellphones, e-mails on their computers, direct-mail fliers, and wall-to-wall ads - many of the attack variety - on their television sets, plus many more on radio. Brown also spent about $500,000 on newspaper ads across the state the Sunday and Monday before the election.

The explosion of late spending was all the more remarkable because the campaign lacked excitement until the last 10 days, when polls showed it tightening, the national ramifications became clear, and a torrent of money poured into the Bay State as never before. Only a few weeks earlier, both campaigns were running on fumes after winning their respective primaries.

A flood of national money propelled Republican Scott Brown’s historic upset of Democrat Martha Coakley in the race for the seat long held by Edward M. Kennedy. Brown’s triumph helped tip the balance of power in Washington, giving Senate Republicans enough votes to block Democratic initiatives.

Candidates and groups that supported them spent nearly $23 million on Tuesday’s US Senate election, burning through nearly all of it in the frenzied final three weeks of the contest, including $8.5 million on television advertising alone during the seven days leading up to the vote.

The state’s last great US Senate race was 14 years ago when Democratic incumbent John F. Kerry withstood a strong challenge from William F. Weld, the Republican governor at the time. About $21 million was spent in that race, said Rob Gray, now a Republican strategist who was Weld’s press secretary in that campaign.

“The Weld for Senate campaign didn’t even have a website, and this was one of the top Senate races in the country,’’ Gray said. “Kerry had one but he was cutting-edge.’’

The pace at which money can be raised, with the help of the Web, from contributors almost anywhere and spent almost immediately continues to accelerate. That has enabled the outside interest groups that have proliferated in the past six years “to impact campaigns very late in the campaign in a way that was impossible before,’’ Gray said.

In the Kerry-Weld race, external sources of funding were much more limited than now. To raise money out of state, the candidates had to get on an airplane and waste a day or two, rather than issuing a plea for contributions online. The national parties each contributed less than $600,000 to their respective candidates and some labor unions provided about $750,000 in aid to the Democrat, Gray said.

Democrats were the early masters of the new technologies, which were raised to an art form by the 2008 presidential campaign of Barack Obama. The special election in Massachusetts showed that Republicans have now also become quite savvy, said Paul Watanabe, a political science professor at the University of Massachusetts Boston.

“It was a mistake for people to think that only the left can organize and use these tools effectively,’’ Watanabe said.

The tone and profile of the race started to change 12 days out, on Jan. 7, when the conservative California-based American Future Fund began a $400,000 ad buy that was critical of Coakley, whose campaign five days later aired a harsh negative spot against Brown.

In short order, each new day brought at least one new outside interest group into the fray. On Jan. 12, the US Chamber of Commerce started what would be $1 million worth of positive ads promoting the Republican upstart. The next day, the Service Employees International Union launched the first of $665,000 worth of negative ads aimed at Brown, and the American Federation of State County and Municipal Employees began $100,000 worth of radio ads promoting Coakley.

In the campaign’s final eight days, 12 different groups aired television spots for or against one of the candidates, spending more than the candidates’ campaigns spent - combined - on TV during that period. During that final sprint, Brown’s campaign spent about $2.2 million and Coakley’s about $1.6 million for ads on broadcast and cable stations in the markets of Boston, Springfield, and Providence, which includes Southeastern Massachusetts, and cable stations in the Albany market, which extends into Berkshire County, according to an analysis by a firm that monitors campaign ad spending.

In the same time period, Coakley’s candidacy was also buttressed by $1.5 million in TV ads down the stretch paid for by the Democratic Senatorial Campaign Committee and a combined $1.4 million in ads paid for by the SEIU, union-funded Citizens for Strength and Security, the League of Conservation Voters, and the Foundation for Patients Rights, the report shows. Brown’s campaign was supported by about $1.9 million worth of ad time purchased by allied groups. Besides the US Chamber and the American Future Fund, they included the Americans for Job Security, Americans for Responsible Health Care, the Employment Policies Institute, the Tea Party Express, and the National Republican Trust.

All told, the Democrat and her allies spent $4.4 million on TV in the last eight days; Brown and his allies spent about $4.1 million, the report said.

© Copyright 2010 Globe Newspaper Company.