PORTLAND — The nation’s last full-time sardine cannery is being given a second life four months after it closed with a company agreeing to buy it and operate it as a lobster-processing facility.

Bumble Bee Foods LLC announced today it had agreed to sell the former Stinson Seafood plant in Prospect Harbor to Massachusetts-based Live Lobster Co. Inc.

The plant was the victim of declining sardine consumption and foreign competition, and Bumble Bee shuttered it in April after a century of operation, putting nearly 130 employees out of work.

Live Lobster expects to create up to 40 jobs in the first year and 120 within two years. The plant at first will be used to buy and sell lobsters, with lobster-processing operations beginning next year.

Officials said the purchase is expected to be completed within 70 days. The sales price was not disclosed.

“Live Lobster has assured me that the company is committed to Maine, to Prospect Harbor and to building a state-of-the-art seafood processing facility,” Gov. John Baldacci said.

At one time, there were dozens of sardine canneries along the Maine coast putting out more than 300 million cans a year at their peak. But the number of canneries fell as U.S. consumption declined and foreign competition increased.

Before the plant closed in April, it was the last full-scale sardine cannery in the U.S. There is a small cannery in California that has been canning small numbers of sardines for a company in Monterey.

San Diego-based Bumble Bee, which bought the Stinson plant in 2004, said it was forced to close the facility because sharp cuts in the amount of herring that fishermen are allowed to catch in New England waters has made it difficult to get enough fish to pack as sardines.

Live Lobster is based in Chelsea, Mass., and operates several plants in Maine.