The Boston Teachers Union denied Wednesday any involvement in a massive television advertisement buy in the final days of the Boston mayoral race by its national affiliate that is believed to have helped propel Martin J. Walsh to victory over Councilor John R. Connolly, a longtime adversary of the union.

In a strongly worded statement sent to its members, the Boston Teachers Union thanked the American Federation of Teachers — the country’s second-largest educators union — for its $480,000 ad buy on behalf of Walsh but said it had no prior knowledge of the group’s involvement in the race.

“The funds came directly from the AFT treasury as the AFT recognized the importance of the election,” read the statement, which was provided to the Globe by Richard Stutman, president of the Boston Teachers Union. “The BTU had no prior knowledge of, and gave no prior approval to, this donation.”

While the Boston Teachers Union did not formally endorse either candidate, Stutman sent an e-mail to members on Election Day offering his personal endorsement of Walsh. He declined to comment further.

Last week’s disclosure that the American Federation of Teachers was behind the late ad campaign from the mysterious “One Boston” political action committee illuminated the extent to which Boston’s mayoral contest served as a major battleground for the national clash between charter school advocates and teachers unions.

All told, national education groups poured more than $1.8 million into the mayoral race. Behind labor unions, it was the second-highest amount spent by any
interest group.

“Boston was one of the few competitive high-profile races around the country where those dollars could make a difference,” said Peter Ubertaccio, a political science professor at Stonehill College. “Boston became a battleground because of the belief that Connolly would be much more favorable to reforms that would dilute teachers unions over time.”

Connolly and his supporters have said they believe the Boston Teachers Union leader’s last-minute endorsement of Walsh and the American Federation of Teachers’ after-the-vote spending disclosure were political calculations meant to boost Walsh without hitching his candidacy to the union’s baggage.

Polls show that teachers unions remain unpopular with large swaths of the electorate. Had voters known the national teachers union was spending so heavily for Walsh, political observers agree, it could have buoyed Connolly’s campaign.

“It’s remarkable that both the AFT and BTU calculated that a public endorsement would hurt Walsh,” said Liam Kerr, the state director Democrats for Education Reform, which spent more than $1.3 million on behalf of Connolly.

The lion’s share of the national education money spent in the race supported Connolly, a self-branded reformer with a history of clashes with the Boston Teachers Union who spent much of the campaign vowing to rid the public schools of “dysfunctional bureaucracy.”

In addition to Democrats for Education Reform, which is funded in large part by a New York nonprofit that does not disclose its donors, Connolly was backed by Stand For Children, an at-times controversial group whose donor list includes such corporate interests as the Walton family and the Bill & Melinda Gates Foundation.

During the preliminary vote, Stand For Children pledged $500,000 on behalf of Connolly. But with some progressives denouncing the group’s corporate backing and government watchdogs decrying outside spending, Connolly asked that such groups not spend money in the race.

Despite its six-figure promise, Stand for Children listened to Connolly, ultimately spending just $8,800 on his behalf.

Walsh’s campaign war chest was boosted by tens of thousands of dollars in individual labor contributions; he also benefited from hundreds of thousands of dollars spent independently on his behalf by labor.

State campaign finance records show that no teachers unions disclosed giving money directly to Walsh’s campaign, instead the American Federation of Teachers donated $500,000 to One New Jersey, a political action committee that has a history of spending money against candidates who have clashed with teachers unions.

That group then set up One Boston, a local political action committee, which funded the late advertising blitz.

The emergence of One Boston shocked political observers, who could not track down any information about where the group or its money was from. Last week, officials with One New Jersey and the American Federation of Teachers disclosed that the national union had bankrolled the political action committee.

The American Federation of Teachers “supports candidates who support working families, and that is exactly what we did in Boston,” its president, Randi Weingarten, tweeted after the disclosure went public. Asked by another Twitter user why the union did not make the disclosure sooner, Weingarten tweeted in response: “No req’t to disclose. ... This was abt Marty Walsh’s record helping working people.”

A spokesman for Weingarten did not respond to an inquiry about the disclosure’s timing.

Under Massachusetts law, One Boston is not required to disclose its donors until January, while One New Jersey is not ever required to disclose its donors under that state’s laws.

The after-the-vote disclosure angered Connolly supporters, who said the teachers union’s attempts to propel Walsh to victory should have been revealed to voters.

Walsh has previously noted that campaign finance laws prohibited him from any coordination with the American Federation of Teachers or other outside groups that spent on his behalf but has asked for transparency with regard to where the money came from.

In previous interviews, Connolly predicted that the Boston Teachers Union would attempt to distance itself from the One Boston expenditure and said he was angered by the lengths the American Federation of Teachers went to keep their donation secret until after the election.

“I believe in our teachers who go into the classroom every day. I wish I believed in the leaders of the teachers union the same way,” Connolly said in an interview Dec. 27, hours after American Federation of Teachers’ role became public. “What is it that they don’t want the people of Boston to know? That part distresses me.”

But political observers and even some activists who spent money for Connolly note that the national teachers union helped propel a candidate in Walsh who holds many reform-oriented stances.

They point out that Walsh was a board member of a charter school and testified on behalf of eliminating the state’s cap on new charter schools.

“Marty Walsh has consistently placed the interests of kids before those of union leaders,” Kerr said. “Nothing I’ve seen from Marty Walsh indicates he would abandon those principles for $480,000.”