This paper describes a practical and reliable algorithm for implementing an Attitude and Heading Reference System (AHRS). This kind of system is essential for real time vehicle navigation, guidance and control applications. When low cost sensors are used, efficient and robust algorithms are required for performance to be acceptable. The proposed method is based on an Extended Kalman Filter (EKF) in a direct configuration. In this case, the filter is explicitly derived from both the kinematic and error models. The selection of this kind of EKF configuration can help in ensuring a tight integration of the method for its use in filter-based localization and mapping systems in autonomous vehicles. Experiments with real data show that the proposed method is able to maintain an accurate and drift-free attitude and heading estimation. An additional result is to show that there is no ostensible reason for preferring that the filter have an indirect configuration over a direct configuration for implementing an AHRS system.