A Vineyard Haven man charged with attempted murder and unlawful possession of firearms and an explosive device was released on $20,000 bail after a dangerousness hearing Tuesday morning.

Matthew Gamache, 36, was arraigned last week on charges of domestic assault and battery, attempted murder, intimidating a witness, 24 counts of unlawful possession of a firearm, unlawful possession of ammunition and a charge for possessing an explosive device.

Bail had been set at $250,000 at a hearing last week. At Mr. Gamache’s subsequent arraignment, the commonwealth requested that he be held pending a dangerousness hearing, which took place Tuesday morning.

Under Massachusetts state law, judges can decide at a dangerousness hearing whether the defendant is dangerous and can order them held for up to 90 days. The judge can also set conditions for release at the hearing.

Hon. Joseph I. Macy presided in court Tuesday.

Cape and Islands assistant district attorney Michael Patterson called Tisbury police officer Jeremie Rogers and the alleged victim to the stand to recount what they said took place on March 5 at a Vineyard Haven home. According to their testimony and a police report, a fight between Mr. Gamache and a woman he knows escalated, and he allegedly kicked her out of bed, put his hand on her throat and head-butted her in the face. He also allegedly tried to stop her from calling the police. She later left the home and came back and called the police. Mr. Gamache was arrested in Edgartown.

When police searched the house, they allegedly found 24 firearms in a locked room in the basement, as well as ammunition, black powder and packing devices. Police also allegedly found a small jar containing what appeared to be an explosive device. The state police bomb squad later came to the Island and examined the device, Mr. Patterson said, adding that black powder was located inside. He said Mr. Gamache did not have a license to carry firearms in Massachusetts.

The alleged victim told the court on Tuesday that Mr. Gamache was a skeet shooter who was generally safe with his guns. She said some of the guns belonged to friends and he was storing the guns for them. She said she was not in fear of Mr. Gamache and she had changed the terms of a restraining order against him to a no abuse order.

Defense attorney Robert Moriarty suggested that the bomb was a fishing bomb. He called Steve Purcell, the owner of Larry’s Tackle, as a witness. He asked Mr. Purcell about fishing bombs, which Mr. Purcell said fishermen have been using for hundreds of years to attract fish.

Under questioning from Mr. Patterson, Mr. Purcell said he had never heard of anyone using a fishing bomb in Massachusetts nor had he ever used one or seen one.

Mr. Moriarty argued that Mr. Gamache was not dangerous and that if he was deemed so, he should be released with conditions to satisfy those concerns. He said Mr. Gamache is a contractor and he and his employees would lose work if he was held without bail.

Mr. Patterson asked that Mr. Gamache be held because of the nature of the charges, including the incendiary device, and his past record.

Judge Macy said he considered Mr. Gamache dangerous and said he didn’t believe the explosive device was a legitimate fishing tool. “That’s as much a booby trap as it is a fish bomb so don’t tell me about what this is or isn’t,” he said.

He said he wasn’t sure what Mr. Gamache was doing with the explosive device. “That’s why I think he’s dangerous,” he said, adding that he believes the alleged victim needed protection.

Mr. Macy set bail at $20,000 and ordered Mr. Gamache to abide by a curfew, to report to probation twice a week, not to possess firearms or other devices, to stay away from a Vineyard Haven home, not to leave the Vineyard, and to wear a GPS device.

Bail was posted on Tuesday. A probable cause hearing was scheduled for April 4.