BOSTON — Lawmakers were told Monday that unsafe, abandoned or obsolete dams are “time bombs” that pose a threat to public safety and wildlife habitats in Massachusetts and need to be repaired or dismantled as quickly as possible.

A public hearing was held on legislation that would require the state to identify all dangerous dams on public or private property and order the removal of any that cannot be returned to safe operation.

The measure co-sponsored by Sen. Marc Pacheco would also create a $20 million revolving loan fund for private dam owners who cannot afford to fix or remove their structures. Cities and towns would be authorized to borrow funds that could be repaid over a 40-year period to deal with unsafe municipal dams, Pacheco said.

Several experts told the Joint Committee on Environment, Natural Resources and Agriculture that the majority of dams in the state were built for industrial-era purposes and have long since outlived their original purpose.

“Failure of one of these dams could result in loss of life or significant property damage,” said Peter Richardson, senior vice president of the Boston Society for Civil Engineers.

Many people who live downstream from the structures are unaware of the danger they pose, said Richardson, who compared the dams to “hundreds of potential time bombs waiting to go off.”

There are about 3,000 dams in Massachusetts. A state audit report issued in January rated 100 of the dams to be unsafe or in poor condition.

Richardson and other witnesses cited the 2005 failure of a 173-year-old wooden dam in Taunton, which forced nearly 2,000 city residents to evacuate.