Pervasive computing applications often involve sensor-rich networking environments that capture various types of user contexts such as locations, activities, vital signs, and so on. Such context information is useful in a variety of applications, for example, monitoring health information to promote independent living in "aging-in-place” scenarios, or providing safety and security of people and infrastructures. In reality, both sensed and interpreted contexts are often ambiguous, thus leading to potentially dangerous decisions if not properly handled. Therefore, a significant challenge in the design and development of realistic and deployable context-aware services for pervasive computing applications lies in the ability to deal with ambiguous contexts. In this paper, we propose a resource-optimized, quality-assured context mediation framework for sensor networks. The underlying approach is based on efficient context-aware data fusion, information-theoretic reasoning, and selection of sensor parameters, leading to an optimal state estimation. In particular, we apply dynamic Bayesian networks to derive context and deal with context ambiguity or error in a probabilistic manner. Experimental results using SunSPOT sensors demonstrate the promise of this approach.