A spokesman for the president's office, Homero Figueroa, said in a video posted to Twitter on Monday afternoon that a suspect, identified as Miguel Cruz, was arrested.
Figueroa said Cruz was a childhood friend of the minister, without giving a potential motive for the attack.
Employees at the Ministry of Environment and Natural Resources told journalists that they heard at least seven shots from within the building. Police units arrived on the scene shortly after.
Mera, a 55-year-old lawyer, was the son of former President Salvador Jorge Blanco, who was in office from 2002 to 2006.
He is survived by his wife, Patricia Selma Villegas, and his two children. His son, Orlando Jorge Villegas, is a federal legislator and member of the Modern Revolutionary Party.
The president and the government have made themselves available to the minister's family, Figueroa said.