Abstract Accurate automated detection of P waves in ECG allows to provide fast correct diagnosis of various cardiac arrhythmias and select suitable strategy for patients’ treatment. However, P waves detection is a still challenging task, especially in long-term ECGs with manifested cardiac pathologies. Software tools used in medical practice usually fail to detect P waves under pathological conditions. Most of recently published approaches have not been tested on such the signals at all. Here we introduce a novel method for accurate and reliable P wave detection, which is success in both normal and pathological cases. Our method uses phasor transform of ECG and innovative decision rules in order to improve P waves detection in pathological signals. The rules are based on a deep knowledge of heart manifestation during various arrhythmias, such as atrial fibrillation, premature ventricular contraction, etc. By involving the rules into the decision process, we are able to find the P wave in the correct location or, alternatively, not to search for it at all. In contrast to another studies, we use three, highly variable annotated ECG databases, which contain both normal and pathological records, to objectively validate our algorithm. The results for physiological records are Se = 98.56% and PP = 99.82% for MIT-BIH Arrhythmia Database (MITDP, with MITDB P-Wave Annotations) and Se = 99.23% and PP = 99.12% for QT database. These results are comparable with other published methods. For pathological signals, the proposed method reaches Se = 96.40% and PP = 91.56% for MITDB and Se = 93.07% and PP = 88.60% for Brno University of Technology ECG Signal Database with Annotations of P wave (BUT PDB). In these signals, the proposed detector greatly outperforms other methods and, thus, represents a huge step towards effective use of fully automated ECG analysis in a real medical practice.