Objective. Brain–machine interfaces (BMIs) provide a direct pathway between the brain and external devices such as computer cursors and prosthetics, which have great potential in motor function restoration. One critical limitation of current BMI systems is the unstable performance, partly due to the variability of neural signals. Studies showed that neural activities exhibit trial-to-trial variability, and the preferred direction of neurons frequently changes under different conditions. Therefore, a fixed decoding function does not work well. Approach. To deal with the problems, we propose a novel kernel regression framework. The nonparametric kernel regression is used to fit diverse decoding functions by finding similar neural patterns to handle neural variations caused by varying tuning functions. Further, the representations of raw neural signals are learned by Siamese networks and constrained by kinematic parameters, which can alleviate neural variations caused by intrinsic noises and task-irrelevant information. The representations are jointly learned with the kernel regression framework in an end-to-end manner so that neural variations can be tackled effectively. Main results. Experiments on two datasets demonstrate that our approach outperforms most existing methods and significantly improves the robustness in challenging situations such as limited samples and missing channels. Significance. The proposed approach demonstrates robust performance with different conditions and provides a new and inspiring perspective toward robust BMI control.