Human rights groups had urged Spain to call attention to President Teodoro Obiang Nguema's record of alleged human rights violations. The game, however, was played without any protest.
Santi Cazorla opened for Spain in the 13th minute before Jimmy Bermudez pulled 119th-ranked Equatorial Guinea level in the 36th. Juanfran Torres slotted the winner in the 42nd.
Midfielder Xavi Alonso was forced to leave the pitch in the first half in his first game back for Spain this season.
Spain coach Vicente del Bosque said, however, that Alonso's injury didn't appear serious, describing it only as "a knock."
"It was an uncomfortable match for us and they played very physically," said Del Bosque. "They didn't let us play our game. They came at us. Our players drew back somewhat and at times weren't focused."
Spain became the first team from outside Africa to play in Malabo since Obiang took power in a coup in 1979 after the small African country gained independence from Spain in 1968.
Opposition leaders to Obiang exiled in Spain also criticized the match, arguing it would help cleanse his tarnished image.
Even so, the Spanish federation failed to clarify the reason for the friendly.
The federation said it hadn't received any extra fees to play. Its president Angel Maria Villar refused to answer any questions regarding the team's trip earlier this week.
Barcelona defender Marc Bartra started in his international debut for Spain.
Alonso made his return since missing last summer's Confederations Cup due to injury, but he had to be substituted after being fouled by Thierry Fidjeu. Real Madrid lost Alonso's midfield partner, Sami Khedira, for six months after he tore a right knee ligament playing for Germany on Friday.
Spain dominated early and went ahead when Cazorla tapped in a cross goalkeeper Danilo Clementino let slip through his hands and fall to the midfielder in front of the open net.
Equatorial Guinea gave Spain's untested pair of centre backs Bartra and Inigo Martinez work as it sought to equalize through Ivan Bolado and Javier Balboa.
Balboa passed for Bolado to volley the ball off Bartra inches over the crossbar, and Bermudez headed the resulting corner kick off the turf and beyond goalie Pepe Reina to ignite the 18,000 home fans.
Spain regained the lead while briefly playing with 10 men waiting for Sergio Busquets to replace the hurt Alonso. Juanfran started a move that ended with the Atletico right back blasting in a rebound after Danilo blocked a cross.
Human Rights Foundation had asked the Spanish team and federation to use the match to draw attention to what the group's president, Thor Halvorssen, called "the appalling human rights abuses in Equatorial Guinea, a country that currently has at least a dozen political prisoners in jail."
Spain will next travel to South Africa for a friendly on Tuesday, its first trip to the country since it won the World Cup there in 2010.
Spain qualified first in its group for next summer's World Cup in Brazil, where it will look to defend its title.Suggest a correction