The Lincoln Mill clock tower, which came within days of being demolished last year, has been saved by an ambitious campaign that raised more than $25,000 to cover the cost of moving it from a location city officials have said is unsafe and in violation of city rules.

The clock tower, which once called thousands of workers to the Biddeford textile mills, became a point of contention in recent years between people who wanted it preserved and others who called the dilapidated structure an eyesore. City officials said its location on the ground between the Lincoln Mill and sidewalk created a safety hazard and violated city code, and won a court order requiring it to be removed.

Supporters of the clock tower announced this week that more than $25,000 was raised through an online campaign and a gift from the Sam L. Cohen Foundation, more than the estimated $17,000 cost of moving it to a new location where it can be renovated.

“We feel it’s important to take this piece of architectural history that has been such a negative image for so long and turn it into something positive and give it new life, as many of the developers have done with the mills,” said Victoria Eon, a board member for the Biddeford Mills Museum. “It’s a huge turning point for the city.”

The clock tower came close to being demolished last September, after the city got a court order that allowed it to fine the Lincoln Mill owners $100 a day if the tower was not removed. Dumpsters were onsite to collect pieces of the tower when George Collord, a local expert on industrial history, stepped in to save it. He bought the clock tower from the Lincoln Mill owners for $1, then posted a $5,000 bond to ensure its removal by May.

In May, the City Council gave Collord until Sept. 2 to move the clock tower from the side of Lincoln Street or the city would have it dismantled and removed. He would like to restore the clock tower and eventually display it in a public space.

“It’s the Union Station of Biddeford,” Collard said when the campaign launched, referring to the Portland train station that was demolished in 1961, sparking that city’s historic preservation movement.

An online crowdsourcing campaign raised about $5,700. An anonymous $10,000 donation was matched by a $10,000 gift from the Sam L. Cohen Foundation.

The fundraising campaign centered on a video produced by Biddeford High School students that documented the history of the clock tower, which was removed from the mill building in 2007 and stripped of its bell and weather vane. The clock tower was built around 1853 and moved to the top of the Lincoln Mill from a nearby building sometime in the 1880s or 1890s.

“I’ve lived here my whole life and I don’t remember what it looked like when it was on top of the building,” said Eon, who attends McGill University in Montreal. “I can only remember the image of it sitting on the side of the road rotting. It’s been such a tragedy for this city.”

The clock tower will be moved on a Saturday in August to the parking lot of Building 10 of the Pepperell Mill Campus, on the other side of the mill complex from its present location, where it will stay while it is restored, said Scott Joslin, the campus’s chief operating officer. He is working with Collord to develop a restoration budget, which is likely to total well over $100,000. The exact date for the move has not been set.

Jeff Cabral, president of the Biddeford Mills Museum board, said much of the credit for the successful first phase of fundraising goes to the students who created the video to draw attention to the cause. Supporters will launch a second phase of fundraising after the clock tower is secured and moved.

Cabral said the success of the first round is a promising sign that people in and around Biddeford are supportive of the concept.

“It’s a win for local history and a win for Biddeford textile history,” he said.