Cuellar was traded along with Ron Taylor to the Houston Astros for Hal Woodeshick and Chuck Taylor at the June 15 trade deadline in . Upon joining the starting rotation in 1966 for the Astros, Cuellar won his first six decisions. The last of them was a 3–2 complete game over the Cardinals at the Astrodome on June 25, in which he recorded a career-high 15 strikeouts. In his final start of the campaign, a 4–3 road win over Cincinnati in the second match of a September 28 twi-night doubleheader, he hit his first major-league home run off of Sammy Ellis to lead off the top of the fifth. Cuellar finished at 12–10, with a 2.22 earned run average (ERA) which was second in the National League to Sandy Koufax's 1.73. Cuellar improved his win-loss record to 16 victories in 1967 for the Astros, setting a team record for left-handed pitchers. (This stood for six years until Dave Roberts surpassed it with 17 in 1973). He made the first of four Major League Baseball All-Star Game appearances at Anaheim Stadium on July 11. He came into the contest in relief of Chris Short in the 11th. Of the seven batters he faced, the only baserunner he allowed in the two shutout innings he pitched was Carl Yastrzemski who hit a two-out single in the 12th inning. Cuellar was traded to the Baltimore Orioles in December 1968. Finally, he had established a permanent role with one of baseball's up-and-coming franchises, as he found spot in the Orioles' starting rotation. With the acquisition of Cuellar, joining the likes of Jim Palmer and Dave McNally, and sluggers Frank Robinson, Brooks Robinson and Boog Powell, the Orioles began one of the strongest sequences of years in professional baseball in 1969. In August of that year, Cuellar accomplished a sequence where he retired 35 batters in a row, without issuing a walk or giving up a hit. The streak was ended on Sunday, August 10 by César Tovar of the Minnesota Twins, as Cuellar was three outs away from recording his first career no-hitter; Tovar's hit, which came in the top of ninth inning, was the only one the Twins would manage against Cuellar in his complete-game shutout (a 2-0 home victory). During the 1969 season, Cuellar achieved a win-loss record of 23–11, struck out 182 batters, and recorded an excellent 2.38 earned run average, as Baltimore won a club-record 109 games and the very first American League East Division title (prior to the season, both the American League and National League had been divided into East and West Divisions).