Emergency workers in El Salvador rescued a man who was trapped for three days by a cave-in while digging a well in the town of San Miguel, authorities said Thursday.

Dagoberto Moya, 38, was rescued Wednesday night and immediately taken to a hospital in San Miguel, some 138 kilometers (85 miles) east of the capital, emergency workers told reporters.

Meanwhile, Salvadoran President Mauricio Funes in a communique expressed his "satisfaction over the rescue" of the worker, whom he said - citing medical personnel attending him - "is out of danger."

Moya became trapped several meters (yards) below ground on Sunday afternoon along with two other workers, who were rescued immediately, when they were digging the well at a local residence.

According to the emergency organizations, Moya always had most of his body free, but his feet were pinned by rocks and earth up to about his knees and his chest was being pressed by a large rock.

They added that the rescue was made difficult by the fragility of the ground, which presented the risk of new cave-ins.

Emergency workers supplied Moya with water, saline solution, vitamins and protein to keep him alive, and they conversed continuously with him from the entrance of the well to keep his spirits up.

Members of the Red Cross, armed forces, fire department, police and other institutions all worked together in the rescue operation. EFE