The evergreen 37-year-old -- who made her international debut for Spain in 1996 -- won on countback after clearing 1.97m with three other women.
Mirela Demireva of Bulgaria took the silver medal while Blanka Vlasic of Croatia took the bronze.
Beitia's victory makes her the oldest ever winner of a jumping event at the Olympics.
The victory comes four years after Beitia retired from the sport following a bitterly disappointing fourth place finish at the London 2012 Olympics.
Beitia however returned to competition several months later to earn a bronze medal at the 2013 World Championships in Moscow.
She came into the Olympics fresh from a victory in the European Championships in Amsterdam with a season's best jump of 1.98m.