A California construction worker is expected to make a full recovery after six nails were shot into his head in an accident with a high-powered nail gun.

The 39-year-old worker, Isidro Mejia, was atop an unfinished home when he fell from the roof onto a co-worker who was using the nail gun, according to a Los Angeles County Sheriff's Department official.

The two workers tried to grab each to keep from falling, but both tumbled to the ground. At some point, the nail gun discharged and drove half-inch nails into Mejia's head.

The nails are powerful enough to drive through three-quarter-inch plywood.

Three nails penetrated Mejia's brain, and one entered his spine below the base of his skull. Doctors said the nails barely missed his brain stem and spinal cord, preventing paralysis or death.

One doctor called the recovery "close to a miracle."