Around 1:40 p.m. two men entered the Bank of the West at 39533 Paseo Padre Parkway in Fremont, police spokeswoman Geneva Bosques said.
Both suspects had their faces partially covered with bandanas and simulated weapons underneath their clothing.
The pair fled in a maroon pickup truck with an undisclosed amount of cash, she said.
Newark police said they received a tip that a suspicious vehicle matching the truck's description had stopped in Newark.
Around 2:05 p.m. Newark police reported to Fremont investigators that the suspect vehicle had stopped at Mowry Avenue and Cedar Boulevard in Newark and two men were seen running from the truck, Bosques said.
Fremont police responded and determined the two men were in a room at the E-Z 8 Motel at 5555 Cedar Court in Newark, Bosques said.
Police surrounded the motel and attempted to contact the suspects.
Around 3:30 p.m. one of the suspects, a man in his mid-30s, exited the room and was taken into custody, Bosques said.
She said he was uncooperative with police.
The second suspect remained barricaded in the room for several hours, and Newark and Union City police SWAT teams and hostage negotiators responded, according to Newark police.
After about five hours, negotiators talked the second suspect into surrendering peacefully, Newark police said.
The names of the two suspects have not been released.