SAN JOSE — A man who held his 3-year-old daughter captive in a Willow Glen home surrendered peacefully after stalemating police for nearly six hours Thursday, during which he released his child to authorities who had surrounded him.

The man, identified as 34-year-old Thomas Chalmers, of San Jose, appeared to be in good health when escorted by police officers to waiting paramedics, who took him to a hospital for evaluation.

Over the course of a tense afternoon, a police negotiator worked to maintain contact, SWAT officers deployed at least 10 flashbang grenades into the home, and at one point a police helicopter flew low over the home, with its siren blaring, in an apparent attempt to flush out the man.

“We started to make more aggressive moves,” San Jose police Lt. Mike King said. “At some point, he decided it was time to come out.”

The encounter began about 9:55 a.m. when police got reports of a possible hostage situation in the 1700 block of Jonathan Avenue near Pine Avenue. Responding officers were told that a man armed with a black handgun was inside a home with his young daughter.

Because of the weapon report, police summoned the MERGE unit — the department’s SWAT team — and cordoned off Pine between Coastland and Ellen Avenues and closed nearby River Glen Park.

Neighbors said the man and his estranged wife were signing papers on a car in the driveway when, without warning, he pulled out a gun and took the child inside the house. The wife was staying with relatives, and no one else was in the house at the time. The couple have three children, including two young school-age kids.

Ron Vierra, who lives across the street, was retrieving a garbage can when the wife came out of the house, yelling for help.

“She said, ‘He’s taking my baby,’ ” said Vierra, 63.

The wife then ran into Vierra’s home. Vierra went to confront the husband, who walked out of the house moments later.

“I said, ‘Look, buddy, I don’t know what’s going on, but you’re not taking that baby anywhere,’ ” Vierra said.

The husband didn’t respond and retrieved a backpack from his pickup truck. When the husband walked back to the house, Vierra saw that he was carrying a handgun by his side. Vierra said he backed up and yelled at a crew building a house on Jonathan Avenue to call 911.

But Vierra wasn’t done intervening. He jumped into his vehicle and used it block in the husband’s truck.

“My main focus was: Don’t let him take the baby,” he said.

Looking back on the incident, Vierra acknowledged that he could have easily been injured — or worse.

“I thought, this is exactly how people get killed,” he said. “I just thank my lucky stars I didn’t get killed, that no one got killed.”

King said a police negotiator was able to establish a rapport with the man and convinced him to free the child, and two hours after the initial emergency call the girl was being whisked away from the home in the arms of a police officer.

King said the girl was unharmed and was “happy to see her mother.”

Police then worked to get the man to surrender. From 1:30 p.m. to 2:15 p.m., MERGE officers deployed the flashbang grenades, to no apparent effect. That was followed by police prepping their bomb-disposal robot to safely assess the home.

During the standoff, the man spoke with relatives over the phone.

Just after 4 p.m., several officers could be seen taking the man to an ambulance. The man was walking under his own power.

King said police recovered a loaded handgun at the scene. He commended the conduct of officers in bringing about a peaceful resolution.

“I think it’s great — it’s the best of all possible outcomes,” King said. “I’m glad it happened this way.”

Chalmers will be booked on domestic violence-related charges, King said.