AGASSIZ, British Columbia (AP) _ A helicopter swooped into the exercise yard of a maximum-security prison early Monday and in a daring maneuver flew two inmates to freedom.

Officials said a prison guard was shot in the leg during the escape at Kent prison, about 50 miles east of Vancouver.

The prison holds some of the most dangerous criminals in Canada. Almost half the inmates in the all-male facility are kept in protective custody and about one-quarter are serving life sentences.

Dianne Brown, a federal corrections spokeswoman, identified the two escapees as Robert Ford, 32, and David Thomas, 24.

She said Ford was serving a life sentence for first-degree murder while Thomas was serving an eight-year term for robbery.

Ford and two other men escaped from a prison in Victoria in March 1989 while awaiting trial. They were captured 11 days later.

Lori Stevens, who lives across the road from the prison, witnessed the escape from her living room. ''It was fun to watch. It looked like a bad movie,'' she said.

The Bell 206 helicopter and its pilot, Fred Fandrich, had been hijacked from Valley Helicopters Ltd., said a Transport Canada official. Fandrich owns the company.

At about 8:40 a.m. the helicopter touched down inside the prison's inner fence and a man inside the helicopter opened fired at Corrections officer Ripley Kirby, hitting him in the leg, police said.

Police said two inmates emerged from a nearby workshop, ran to the helicopter and jumped aboard.

''I was told to get out of there, so I got out of there,'' said Fandrich, 50.

''There was a lot of gunfire inside the helicopter from the guy with the gun and it was very, very loud when he's shooting a foot away from your head,'' the pilot added.

The helicopter was then flown to Silver Creek, about 50 miles north of the prison. Police said Fandrich was tied up and the two escapees and an accomplice left the area in a bluish-gray car.

Fandrich managed to escape and contact police.

The escape was the second since Kent opened in 1979. Assistant warden Judy Croft said two inmates escaped eight years ago by hiding in a truck as it left the grounds. They were captured less than an hour later.

Dennis Finlay, another federal corrections spokesman, said the situation at the prison was under control. The prison has 260 inmates.

A similar attempt failed in February in France when three gunmen hijacked a helicopter and forced the pilot to fly to a maximum-security prison south of Paris. The hijackers dropped a rope from the helicopter, but it snapped as prisoners grabbed it. One man was killed and another was seriously injured.

Last August in Colorado, two women in a hijacked helicopter plucked two men from a prison yard. The escape attempt ended in a shootout with police 400 miles away.

A similar prison escape in Miami in April ended when the helicopter crashed inside the prison yard.