By Tori Richards

RIVERSIDE, Calif. (Reuters) - The man accused of fatally shooting two police officers and wounding a third in Palm Springs, California, over the weekend was formally charged on Wednesday with murder and attempted murder in what prosecutors described as an ambush attack.

The suspect, John Felix, 26, would be eligible for the death penalty if convicted as charged, but Riverside County District Attorney Mike Hestrin said he would decide later whether to seek capital punishment.

The two officers slain on Saturday, the latest of several cut down in a string of ambush-style attacks on police across the country in recent months, were the first killed in the line of duty in 54 years in Palm Springs, a normally placid desert resort town about 100 miles (160 km) east of Los Angeles.

One was a 63-year-old veteran of the Palm Beach police force who planned to retire in December and the other a 27-year-old rookie officer who had just returned to duty from maternity leave.

They were shot through the closed front door of a home as they responded to a report of a family disturbance at the address, prompting a gunfight between police and the suspect that stretched into a 12-hour-long standoff, according to authorities.

"This individual knew what he was doing. He was deliberate in his actions and attacked these officers for no reason other than they were coming to a call," Hestrin said. "I would describe this as an ambush. These police officers walked into a trap."

Felix, who also was injured during the confrontation, surrendered to police early the next morning.

In addition to two counts of murder, he was charged with three counts of attempted murder - one each for three other officers involved in the shootout, including one who was wounded by gunfire. That officer was treated at a hospital and released.

Felix also was charged with various weapons offenses, including unlawful possession of a weapon by a convicted felon. California criminal records show he previously served time in prison for assault with a firearm.

Authorities said Felix was armed with a stolen assault-style rifle, used armor-piercing ammunition and wore body armor at the time of Saturday's incident.

He was scheduled to appear in court on Thursday for an arraignment.

Hestrin, appearing at a news conference to announce the charges, declined to comment on a possible motive for the shooting.

(Reporting by Tori Richards in Riverside; Writing by Steve Gorman; editing by Grant McCool and Jonathan Oatis)