A mudslide prompted by heavy rains derailed four CN Rail cars and slightly injured two workers early Tuesday morning.

CN spokeswoman Kelli Svendsen said the Canadian Pacific freight was being operated by a CN crew and was travelling westbound on CN tracks, 12 kilometres west of Boston Bar in B.C.'s Fraser Canyon northeast of Vancouver.

The cars jumped the rails at about 3 a.m. Tuesday morning, trapping the two CN workers in the cab of the locomotive.

"They were in the locomotive for a short period of time," said Svendsen, noting the men were rescued quickly and were conscious and responsive on the way to hospital.

Svendsen said an initial assessment suggested five boxcars had derailed, but CN later confirmed four cars were involved.

The cars were loaded with copper concentrate and Svendsen said they remained upright, but the locomotive was on its side and a diesel fuel leak had to be contained.

Crews at the scene were checking for any track damage and could not say when the westbound tracks would reopen.

Two avalanches and a rock slide affected roads in the same area as heavy rains and high winds swept across southern B.C.