WASHINGTON — Republican Mitt Romney enjoyed a surge of donations in September, raking in $170 million for the month — a major cash infusion that is helping finance a deluge of advertising by his campaign in the final weeks of the White House contest.

Romney came close to matching the $181 million that President Barack Obama raised last month — and he did so during a rocky period for his candidacy and before his performance in the Oct. 3 debate, an event that greatly energized the GOP base.

Romney campaign officials indicated Monday that October was shaping to be better. Spokeswoman Andrea Saul tweeted the campaign raised more than $27 million in small donations online in the first two weeks, better than any month.

The rapid pace with which Romney brought in contributions in September puts him on track to join Obama in raising more than a record $1 billion.

As of Sept. 30, Romney had pulled in nearly $839 million through his campaign, the RNC and a joint fundraising committee, said the Federal Election Commission and Campaign Finance Institute.

Obama’s campaign and affiliated committees had raised $947 million.