Wireless personal area networks (WPAN) and wireless local area networks (WLAN) based on IEEE 802.15.4 and 802.11 standards operate in overlapping unlicensed frequency bands; therefore, they create harmful interference for each other if deployed in the same geographical area. There has been various performance analysis of the media access control (MAC) protocols for both networks individually. However, the coexistence performance of the two networks is less well-understood, which has been mainly studied via computer simulation. In this paper, we attempt to close this gap by developing a comprehensive mathematical model to evaluate the throughput performance of the carrier sense multiple access with collision avoidance (CSMA/CA) protocols of coexisting 802.15.4 WPAN and 802.11 WLAN. Specifically, we consider two coexistence scenarios, called symmetric and asymmetric scenarios. In the symmetric scenario, wireless nodes in both networks can sense one another while in the asymmetric scenario, only WPAN nodes can sense active WLAN nodes but WLAN nodes cannot sense the transmissions from WPAN nodes. The proposed models effectively resolve the major challenge arising from the fact that the MAC protocols in the two networks operate in different time scales. In addition, we explicitly capture detailed operations and interactions of the underlying MAC protocols. We then propose to employ the developed models for channel allocation to achieve fair throughput sharing among WPAN nodes. Numerical results confirm the excellent accuracy of the proposed models and their usefulness for performance evaluation and design of the heterogeneous network.