Two men were in custody in connection with the incident, but the scene was still "active" later Wednesday morning, with a helicopter and large contingent of law enforcement in the area, officials said.
The El Dorado County Sheriff's Office identified the deceased as Sheriff’s Deputy Brian Ishmael and said on Facebook the incident occurred in the area of Ridge Road and Mount Aukum Road in the unincorporated community of Somerset, located about 60 miles east of Sacramento.
"It is with an extremely heavy heart that we announce that we lost a deputy in the line of duty this morning," the department said.
Sheriff John D'Agostini told reporters later on Wednesday that Ismael and a San Joaquin County deputy responded to a call regarding a theft from a marijuana garden at a private home.
Upon arrival, the deputies immediately came under fire and Ishmael was killed immediately. The San Joaquin County deputy -- whose identity was not released -- was rushed to a hospital where he underwent surgery before doctors released him, police said. He is now assisting deputies in the investigation, D'Agostini said.
A police officer could be seen in a video from Fox 40 standing with his weapon drawn along a roadway near where the shooting took place.
"We ask that you please remain out of this area," investigators said. "Residents, we ask that you remain vigilant and call 911 for any suspicious activity."
Two suspects, both Hispanic men, were taken into custody, D'Agostini said. One had been shot and taken to the hospital. His condition was unknown.
An investigation was ongoing.
Ishmael, a husband, and father of three, was described as a four-year veteran with the El Dorado County Sheriff’s office who previously worked for the Placerville Police Department.
"Our thoughts and prayers are with his family and friends," police said.
A video posted by the department to Facebook showed the procession for the deputy on a nearby road.
Working in law enforcement has been one of the most dangerous jobs in America. As of mid-September, 81 officers had died in the line of duty this year, with causes running the gamut from vehicular accidents and medical emergencies to homicides, according to data from the Officer Down Memorial Page.
Fox News' Greg Norman and Bradford Betz contributed to this report.