The Nasdaq composite rose on Tuesday, led by gains in Apple ahead of the tech giant's quarterly earnings release.

The tech-heavy index closed 0.9 percent higher at 7,130.70 while Apple climbed 2.3 percent.

The also rose 0.25 percent to 2,654.80, erasing earlier losses, as Apple's gains pushed the technology sector 1.5 percent higher.

Apple is scheduled to report fiscal second quarter earnings and revenue Tuesday after the close. Apple is the largest publicly traded company in the U.S., with a market cap of nearly $850 billion.

"Tonight's earnings release from [Apple] will likely keep most fundamental investors from making aggressive changes to their risk," said Jeremy Klein, chief market strategist at FBN Securities, in a note to clients. But "even if [Apple CEO] Tim Cook lays an egg tonight, most analysts will assess the Q1 reporting season as an unmitigated success."