ALBANY -- Cassandra Hernandez spent more than 15 hours in hell.

Her nightmare began about 11:30 p.m. Wednesday when she, her boyfriend and two of her young children became the hostages of an armed and suicidal intruder in her apartment at 57 Westerlo St. in the city's Pastures neighborhood.

As minutes turned into hours, Hernandez remained a prisoner of a man with a violent past who was apparently bent on sending a message to his girlfriend in New York City. And it continued even hours after her captor, a convicted felon from the Bronx, agreed to let her boyfriend and children leave.

Then, at about 2:30 p.m. Thursday, her ordeal ended when the man was shot during an exchange with State Police. It was unclear whether the wound, not believed to be life-threatening, was fired by a trooper or self-inflicted, according to a person with knowledge of the situation.

The man, whose name was not immediately made available, was taken out to a stretcher, as was Hernandez, who police said was "pretty shaken up."

The violent resolution came only after the man became "more agitated" and police, fearing for the life of the woman, took action, Albany police said.

"Our ultimate goal was to get the hostage out safely, which we did," said Detective James Miller, a city police spokesman. "He made mention about committing suicide. He was distraught. There were some other issues going on."

Miller said State Police and Albany police were involved as the situation continued. He also noted the man made various requests as police hostage negotiators spoke to him.

At one point he asked for water and a new cellphone battery. And at the request of police, Erin Vannella, a reporter for YNN News, interviewed the man by phone. She later broadcast the audio of the conversation on television.

In the rambling phone conversation, he spoke about financial problems, his battle with multiple sclerosis, and his love for a woman he identified as his wife.

"I want you to put it on the news that I love her," the man told Vannella after detailing his personal problems. "This is for her."

Later, he said, "I'm going to kill myself."

The man told YNN he also had relationship problems and a criminal record. Authorities told the Times Union that his record includes at least one violent felony conviction and that he spent time in state prison.

The suspect told YNN said he went to the home to get money because he is having financial trouble, but that police quickly descended on the scene. He said he believed he was set up.

"That's why I have to stay in the house right now 'cause cops are here," he said.

"There is a lot of stuff that is going on in my life," he said.

The man's girlfriend was flown by police helicopter from New York City and escorted to the scene, but it was not clear whether she and the man spoke.

"His ultimate goal was either to relay a message to his girlfriend or talk to her," Miller told reporters.

The standoff quickly attracted a crowd of media and observers on a bitterly cold afternoon. Police in SWAT gear continually entered and left the building as a large State Police mobile unit remained outside.

A command post was set up near South Pearl Street. Mayor Jerry Jennings was among the officials on hand.

In the meantime, Hernandez's ordeal continued. Hours earlier, she had a tearful speakerphone conversation with her mother, Sylvia Hernandez of Troy, as the man listened.

Sylvia Hernandez said her daughter called her shortly after the standoff began. Cassandra Hernandez was crying as she spoke and asked that her mother come to get the children, she said.

"I cried so much last night that I don't have any more tears. I'm so nervous that I don't know what to say," Sylvia Hernandez said as she stood near the scene.

Sylvia Hernandez said police were already at the building when she arrived late Wednesday night.

She said her daughter lives there with three children, ages 2, 3 and 10. The 10-year-old was staying with his grandmother Wednesday night.

The two children were released during the early hours of Thursday. Hernandez's boyfriend, covered with a quilt, was escorted from the back of the house by Albany police tactical team members after 8 a.m. and driven away in a detective's car.

Several agencies, including State Police and Troy police SWAT teams, joined Albany police at the scene.

The investigation is being handled by State Police. Trooper Maureen Tuffey, a spokeswoman for Troop G in Loudonville, could not be reached Thursday evening.

Staff writer Dayelin Roman contributed to this report. Reach Robert Gavin at 434-2403 or rgavin@timesunion.com