LAWRENCE — Mayor Daniel Rivera celebrated a hard-fought reelection victory on Tuesday after he fended off a comeback attempt by William Lantigua, the controversial former mayor whom he ousted from office four years ago.
Rivera’s supporters, gathered at the Claddagh Pub, broke into cheers, hugs, and dances when an aide announced he was victorious, shortly after polls closed at 8 p.m.
Addressing his jubilant supporters in English and Spanish, Rivera thanked the crowd for working tirelessly on his reelection campaign.
“This is not about Danny Rivera,” he said. “This is about every single person who lives in the community, and tomorrow we’re going to get right back to work because we’ve got things to do.”
Reaching out to supporters of Lantigua, his bitter rival, he said the two camps must unite.
“Tomorrow’s a new day,” Rivera said. “Everyone’s Lawrence again. There’s no Team Rivera. There’s no Team Lantigua. We’ve got to make our city better together.”
Rivera captured 51.4 percent of the vote to Lantigua’s 48.6 percent, according to the Associated Press.
At his campaign headquarters, where a subdued crowd gathered, Lantigua said he wants his supporters to give Rivera a chance.
“I will not be an aggressive opposition to Mr. Rivera, as his people have been to me. It isn’t fair,” Lantigua said. “The election is over. I just hope he learns from his mistakes and how poorly he managed the city. Hopefully, moving forward, he’ll do a better job and, if he does, I will always be there to help out.”
Lantigua refused to rule out another run for office. “I don’t have a crystal ball to tell you what’s going to happen next,” he said.
Rivera’s victory is likely to come as a major relief to the state’s political and business establishment, which was deeply worried about Lantigua returning to power.
When Lantigua was mayor, City Hall was rife with allegations of cronyism, corruption, and graft. Rivera, a former military police officer, has sought to restore trust in government after what he has called the “dark four years that were Lantigua’s Lawrence.”
Still, Rivera faces daunting challenges as he prepares to lead this heavily immigrant, predominantly Latino city for another four years.
One of the poorest municipalities in Massachusetts, Lawrence is grappling with a rise in murders, high unemployment, an opioid crisis, and a school system that remains under state control. City finances are also managed by a state overseer.
Rivera’s supporters said he was well-equipped for the job.
“He’s competent and sheds a good light on the city,” said Sheila Ramirez, 21, a social work major at Saint Anselm College, who voted for Rivera. She said she also appreciated his hiring of a homeless coordinator.
Lantigua, she said, “doesn’t represent the city well.”
“Right now, obviously, Lawrence is going through a lot with the opioid crisis,” Ramirez said outside the Leahy School, her polling place. “A lot of eyes are on us, and I think we need representation that’s able to handle the pressure.”
Edar Valesquez, 50, a carpenter, who voted for Rivera, said he appreciated the mayor’s focus on nuts and bolts.
“He brings more police in the street; he does a lot of work in the parks; and he’s working hard to bring some security to the city,” he said.
Rivera ousted Lantigua from office four years ago by just 81 votes, and his victory was far from certain again this time. A charismatic politician with a populist’s touch, Lantigua is a relentless street-corner campaigner and remains a beloved figure for many in the city, whose residents he refers to as “mi familia.”
“Lantigua, although he doesn’t have a college degree, is somebody from the heart of Lawrence,” said Francisco Paulino, 37, a tax attorney and candidate for City Council who was holding a Lantigua sign outside the Leahy School. “Lantigua is one of us – and when I say one of us, I mean he’s a Lawrence resident who loves this city, who wants to be here for us.”
But Lantigua’s record as mayor was pocked with scandals. Among other troubles, his former chief of staff was sentenced to 18 months in jail for bribery in 2014.
After losing a comeback bid for state representative in 2014, Lantigua spent two years in political exile in his native Dominican Republic before returning to Lawrence earlier this year to challenge Rivera.
Rivera was backed by most of the state’s business and political leaders, including fellow Democrats such as Senator Elizabeth Warren and Attorney General Maura Healey as well as Governor Charlie Baker, a Republican who recorded robo-calls for his campaign.
Under Rivera’s leadership, the city has hired 23 more police officers and overall crime ticked downward. But violence and the opioid epidemic remain serious problems, and the city has had seven murders as of Sept. 30, up sharply from two during the first nine months of 2016.
The local economy has been slowly mending. Still, the jobless rate in September was 6.6 percent — among the highest in the state.
Michael Levenson can be reached at mlevenson@ globe.com.