BATH, Maine — A historic lighthouse lens showcased in the Cape Elizabeth Town Hall lobby for 18 years was to have been returned to the U.S. Coast Guard.

But then the Maine Maritime Museum stepped in.

The Fresnel lens, made in 1874 in Paris, France, was going to be sent to a U.S. government warehouse in Boston after Cape Elizabeth decided it couldn’t afford to keep it any longer.

But now the Washington Street museum will be its new home. The lens, valued at $2.5 million, sat for more than 120 years on the east tower of Two Lights on Cape Elizabeth.

“This lens is a significant cultural artifact with great meaning for the community of Cape Elizabeth,” Amy Lent, the museum’s executive director, said Tuesday in a press release. “I am happy that we learned of the impending move in time to step in and keep it in Maine. Coincidentally, the museum’s current exhibit is about the U.S. Coast Guard in Maine, past and present, including the Lighthouse Service.”

Lent added “it will take time to arrange proper long-term exhibit space and to create an interpretation that will bring this lens to life again. We hope to collaborate with the community to ensure this part of Maine’s heritage is accessible to all visitors who have a fondness for lighthouses in general and the Cape Elizabeth Light in particular.”

Dave Garrison, director of marketing and communications for the museum, said Tuesday that the lens is on loan to the museum from the U.S. government. The lens could cost between $8,000 and $10,000 to reassemble, and the museum will incur slightly higher insurance costs to house the lens.

The Cape Elizabeth Light was automated in 1963, which eliminated the need for a lighthouse keeper, according to the museum. But the lens remained, continuing to operate until being replaced in 1994 by newer equipment. It then went to the Portland U.S. Coast Guard Station for display, and the following year the Coast Guard loaned it to Cape Elizabeth as part of the town’s Portland Head Light collection.

With renovation of Cape Elizabeth Town Hall, the lens had to be moved. Town officials wanted to find a new home for it, and considered moving it into the Town Council chambers. When they learned the loan conditions required the lens to be screened from ultraviolet light and protected from being touched by visitors, that plan was dropped.

If the lens were moved, Cape was required to install window screens to block light, and to construct a glass or plastic enclosure. The framing would also have required a new glazing.

The Coast Guard also wanted the town to hire a “qualified lampist” to dismantle and move the lens.

“Updated conditions and insurance could result in an annual cost of about $7,500 to care for this lens,” Cape Town Manager Michael McGovern wrote in an e-mail to his Town Council, according to the museum. “I recommend we return this lens to the Coast Guard to ensure its long term preservation.”

The council voted April 11 to return the lens to the Coast Guard. But this month, Coast Guard curator Arlyn Danielson, who had recently helped the Bath museum install its Coast Guard exhibit, asked the Bath institution if it might adopt the lens.

“We were very interested,” Nathan Lipfert, the museum’s senior curator, said in the press release. “Maine has more lighthouses than any other coastal state. Pieces of these lights, like the Cape Elizabeth lens, are important technological artifacts, which are difficult and (expensive) to preserve. They are crucial to helping us understand the technology and economics of maritime trade in earlier centuries. They have become cultural artifacts as well, and many people are interested in them.”

Lipfert added that “The Cape Elizabeth Light lens will become the largest lighthouse artifact in our collection, and we look forward to having it in our care.”