The victory snapped a three-match losing streak for San Jose, which advances to play the Chicago Fire in a third play-in match later this month.
It was the Timbers' first loss at their newly refurbished Jeld-Wen Field this season. An announced crowd of 11,412 watched the match.
Opara's header sailed past diving Timbers' goalie Troy Perkins in the 120th minute.
San Jose's Steven Lenhart appeared to score late in the first of two 15-minute overtime periods, but the official ruled that he used a hand. The Timbers got a free kick from about 30 yards out midway through the second period, but couldn't take advantage.
After the 30 minutes of overtime, the match would have been decided on penalty kicks.
The Timbers defeated Chivas USA 2-0 in the first round of play-in matches.
The qualifying matches will narrow the field to 40 teams for the single-elimination tournament, which starts in June and concludes with a final national club championship on Oct. 4. The field will include eight Major League Soccer teams, other lower-division professional clubs, and 21 amateur teams.
The Seattle Sounders are the two-time defending U.S. Open Cup champions.
The Timbers were coming off a 1-0 victory over Real Salt Lake in an MLS match on Saturday night. It snapped Real Salt Lake's 18-game unbeaten streak.
The Earthquakes were coming off a 1-0 loss at the Philadelphia Union on Saturday. San Jose hasn't had a victory since its second match of the season, when it beat FC Dallas 2-0.
The Timbers gave several of their starters the night off, including captain Jack Jewsbury and defender Rodney Wallace. In contrast, San Jose kept many of its starters active for the match, including captain Chris Wondolowski.
San Jose's Brad Ring got an early yellow card for shoving Spencer Thompson, and the Timbers got a free kick from about 40 yards out, but it was deflected by Earthquakes goal keeper Andrew Weber.
The Earthquakes came close in the 75th minute, but Perkins tipped Ryan Johnson's shot just over the crossbar.
The Earthquakes won the two previous U.S. Open Cup matches between the clubs, in 2004 and 2005.