OCEANSIDE (CBS 8/CNS) - A lengthy standoff between an armed man and SWAT officers ended without violence early Sunday in Oceanside.

Police said Matthew James Machonis, 28, threatened officers and refused to leave his apartment after pulling a gun on his girlfriend and threatening to kill her during a fight at their home at about 7 p.m. on the 1600 block of Broadway Street in Oceanside on Saturday.

Machonis' girlfriend managed to wrestle the gun away from him, lock herself in a bathroom and call for help. Police were able to get the woman out safely before the standoff with Machonis began.

Officers said Machonis threatened officers who came close to the apartment that he had an AR-15 assault rifle, that he would fire upon officers and that the standoff "would not end well." His girlfriend told officers she was only aware that he owned a shotgun and semi-automatic handgun.

The Oceanside SWAT and crisis negotiation teams arrived to the residence to assist officers after their attempts to get Machonis to surrender were unsuccessful. Machonis finally surrendered without violence at about 1 a.m. Sunday.

Officers searched the apartment and recovered a Remington 870 shotgun and Glock 40 caliber semi-automatic handgun.

Machonis was booked into Vista Detention Facility under suspicion of assault with a deadly weapon and domestic battery. His court date was scheduled for April 21 and his bail was set at $50,000.