The eustachian tube which links the middle ear to the throat is the device which maintains pressure inside the ear. The valve at the end of it releases air to equalize the pressure inside and out. The pressure of air decreases as we go higher. Thus while travelling at higher altitudes the air pressure contracts compared to the pressure inside the ear drums resulting in popping of the ears. Popping can wear off with a few actions of swallowing or yawning.