Gil became the first Portuguese man in 17 years to reach an ATP Tour semifinals last week in Johannesburg, and that performance gave him a special exemption entry into the Brazil Open.
He repeated the semifinal effort with a solid performance against Almagro.
Gil earned the first breaks in both sets, only for the Spaniard to break back and force tiebreakers in which Gil showed more composure. Gil converted both of his break chances, while Almagro made only two of 11.
Gil will meet local hope Thomaz Bellucci who, in his debut of an ATP quarterfinals, spoiled Juan Carlos Ferrero's 29th birthday by beating the former French Open champion 7-6 (5), 1-6, 6-3.
"This was a very important victory for me because this is a major tournament in Brazil and this gives the whole thing a very special flavor,'' said Bellucci, Brazil's top player.
Second-seeded Tommy Robredo and fourth-seeded Jose Acasuso will meet in their second semifinal in two weeks. Acasuso prevailed last week in Chile.
"It will be a very difficult game,'' Acasuso said. "Tommy is in good shape.''
Acasuso beat sixth-seeded Eduardo Schwank 6-4, 6-3 in an all-Argentine match, while Robredo defeated Alberto Martin 6-2, 6-2 in an all-Spanish matchup.
Luis Fabiano Leaves Sevilla For Brazil For Knee Rehabilitation
Player Ratings: Racing Santander 1-2 Barcelona
Almagro knocked out by Gil in Brazil Open