Danvers Bancorp Inc said it agreed to buy Beverly National Corp in an all-stock deal worth about $62 million to strengthen its market position in Massachusetts' Essex County.

Under the terms of the deal, Danvers plans to offer 1.66 of its common shares for each Beverly National's common stock.

Danvers' $23.04-a-share bid represents a premium of 36 percent to Beverly National's Tuesday close of $16.90.

The combined company will have about $2.2 billion in assets and about $1.6 billion in deposits, Danvers said.

This transaction... will increase our earnings prospects in the near- and long-term, Danvers' Chief Executive Kevin Bottomley said in a statement. The deal is expected to be completed in the fourth quarter.

Bottomley will continue in the same capacity for the combined company, while Beverly CEO Donat Fournier will become an executive vice president and a member of the senior executive management team at Danvers.

(Reporting by Abhinav Sharma in Bangalore; Editing by Himani Sarkar)