National Security Commissioner Monte Alejandro Rubido said one federal policeman died and another was injured in the three hour battle on a ranch just inside the Michoacan state border with Jalisco, home of Guadalajara, Mexico's second-biggest city.
The death toll was one of the heaviest to hit Mexico since President Enrique Pena Nieto took office in December 2012 pledging to put an end to years of gangland violence that have claimed more than 100,000 lives since 2007 alone.
Government officials said the 42 killed by security forces near the town of Tanhuato were suspected members of the Jalisco New Generation (JNG) cartel, a gang based in the neighboring state that has seriously undermined Pena Nieto's pledge.
The gunfight began after security forces alerted to an "invasion" of the ranch approached the 112 hectare property and were fired upon by a group of armed men, Rubido said.
After calling in air and ground support, government forces ground down their opponents with the aid of a helicopter, in the end capturing three suspected gang members and seizing a grenade launcher and 39 guns of varying calibers, he added.
Earlier, a government official told Reuters that two federal police had died in the exchanges near Tanhuato, where a week ago, federal forces replaced local police after the assassination of a candidate for mayor in a nearby town.
Rubido said officials from the national human rights commission (CNDH) had been sent to the ranch, where the number of dead was the highest in any clash between the government and suspected gangsters since a controversial incident last June.
Jalisco is one of the engines of the Mexican economy, but the state's southern border turned into a battleground between the JNG and the Michoacan-based Knights Templars, a gang whose leadership has been shattered over the past 18 months.
Capitalizing on the Templars' losses, the JNG has become the biggest threat to the government, killing at least 20 police since March. On May 1, its gunmen shot down an army helicopter in southwestern Jalisco, claiming the lives of six military personnel.
The gang also set vehicles, banks and gas stations ablaze around Guadalajara in a series of concerted attacks that day, shaking confidence in the federal government's ability to contain the violence ahead of mid-term elections on June 7.
Pena Nieto's ruling Institutional Revolutionary Party hopes to defend the slim majority it and its allies have in the lower house of Congress, with polls suggesting it could.