Elizabeth Warren, left, holds up a poster of herself as Sen. Scott Brown, R-Mass., right, looks on during the annual St. Patrick's Day Breakfast in Boston on March 18. Warren, a Harvard professor and consumer advocate, is running against Brown. (Michael Dwyer/AP)

An ambitious attempt to effectively bar attack ads by outside groups in the contentious U.S. Senate race in Massachusetts is showing signs of working, at least so far.

Sen. Scott Brown (R-Mass.) this week agreed to pay a penalty for radio and print ads run by the American Petroleum Institute urging people to contact Brown and ask him to vote against raising taxes on energy firms.

The payment is part of a “People’s Pledge” between Brown and Democratic challenger Elizabeth Warren aimed at limiting negative advertising by outside groups. Under the agreement, each side will make a donation to charity equal to half the price of any third-party advertising that violates the deal.

The pact, signed in January, is aimed at providing an incentive for supporters to stay out of the race for fear of financially hurting their favored candidate. Advertising by outside groups in the Massachusetts Senate race has nearly disappeared since the deal was reached, data show.

The agreement was reached in response to loosened restrictions that have made it easier for corporations, unions and wealthy individuals to spend unlimited funds on political ads in the 2012 elections. Attempts to reach similar cease-fire agreements in other divisive Senate races, such as Montana’s, have fallen apart.

In Massachusetts, the agreement has been invoked twice, both times against Brown. This month, the senator donated $1,000 to an autism charity in response to pro-Brown Google ads run by a small Massachusetts political committee.

The latest penalty centers on a multi-state API ad campaign attacking proposals by the Obama administration to close tax loopholes used by energy firms. In Massachusetts, the ads ask people to call Brown’s office urging him to vote against such policies, which he already opposes.

Warren campaign manager Mindy Myers said the ads were “funded by big oil and clearly support Brown’s position on this issue,” making them a violation of the agreement to discourage outside spending.

“If Scott Brown allows these ads to continue, it could open the exact kind of loopholes for third parties that Elizabeth Warren was concerned about from the beginning,” Myers said Monday in a statement condemning the ads. “We urge Senator Brown to honor the pledge and demand that these ads be taken down.”

Brown spokesman Colin Reed said the campaign does not believe the API spots were actually covered by the agreement, because they constituted “issue ads” from a trade organization rather than direct election advertising.

Nonetheless, he said, the API ads “do represent a loophole that needs to be closed.”

“Scott Brown is committed to honoring this historic agreement and for that reason his campaign will donate to charity the sums called for in the pledge as a result of the American Petroleum Institute’s ad campaign,” Reed said in a statement. “The fact that we have now expanded the pledge to cover issue ads is a positive and welcome development.”

Reed said the campaign had not yet determined how much the Massachusetts portion of the API ad campaign cost.

The oil industry group said variations of the ads ran from Saturday to Tuesday in seven states: Massachusetts, Missouri, Maine, West Virginia, Virginia, North Carolina and Nevada.

API spokesman Reid Porter said the ads were “based on public policy currently being debated before the U.S. Senate” and were “not related to campaign activities.”

The race between Brown and Warren is expected to be one of the most expensive Senate campaigns in the nation this cycle. The two candidates raised a combined $17.5 million through December, according to data from the Center for Responsive Politics.

The agreement on third-party ads came in part as a response to the Supreme Court’s 2010 ruling in Citizens United v. Federal Election Commission, which eased the way for unlimited spending by super PACs and other non-campaign organizations. Outside groups on both sides already had poured millions of dollars into the Massachusetts race before the pact was signed.

Lisa Gilbert, deputy director of the Congress Watch program at Public Citizen, said the pledge “does seem to be working.”

“A financial penalty incurred by the very candidate you intended to support through an ad buy seems to be functioning as an effective deterrent in Massachusetts,” Gilbert said. ”This has enabled at least one race to be freed from the game of outside and corporate spending we have seen playing out in the wake of Citizens United.”