The victims were a 14-year-old boy and two women aged 18 and 47, according to a statement by the prosecutors' office in northern Coahuila state.
The statement said gunmen traveling in two vehicles opened fire on a convoy of federal police and soldiers in the city of Saltillo, Coahuila. The officers and soldiers returned fire.
It was not clear who fired the shots that killed the bystanders, but the state attorney general's office said it was investigating and expressed condolences to the victims' families.
"They are civilians who unfortunately died in the exchange of gunfire," it said, describing a running series of confrontations between police and assailants who allegedly fired shots into the air to clear bystanders from their path at one point.
Mexico's army, which has taken a leading role in combating drug gangs, has come under criticism for alleged indiscriminate use of force and firing on civilians.
Three gunmen also died Sunday in a separate shootout in another Coahuila city, Torreon.
Coahuila has been the scene of bloody turf battles between the Sinaloa cartel and the Zetas drug gang.
In the border city of Ciudad Juarez, meanwhile, the death toll from a birthday party massacre late Friday rose to 14 after an 18-year-old male died of his wounds.
Nineteen people were wounded in the attack on two private homes where about four dozen partygoers had gathered for a teen's birthday.
The dead identified so far were 13 to 32 years old, and the majority of the victims were high school students, a survivor said.
While investigators said they have not yet identified the perpetrators or a motive, police found 70 bullet casings from assault weapons typically used by drug gangs at the scene of the shootings. Cartel violence has killed more than 2,000 people so far this year in the city across from El Paso, Texas.
Drug gangs have increasingly attacked private parties that they believe members of rival gangs might be attending; other innocent partygoers are often killed in such attacks.
On Sunday, prosecutors in northern Chihuahua state, where Ciudad Juarez is located, said they were searching for a man known only by his nickname, "The Mouse," who was apparently the target of the gunmen.
The man was reportedly wounded in the Friday shooting, but has disappeared. Investigators said they believe he can shed light on who was trying to kill him.
Memorial services were held Sunday for some of the victims of Friday's attack, and prosecutors said that guards had been provided to protect those services.
Friday's attack recalled a similar massacre in Ciudad Juarez in January, when gunmen killed 15 people at a house party.