A prisoner was being transferred from jail to court when he wrestled away a deputy's gun and shot several people.