Ridwan Alief Prayogi, right, gives a two-finger salute in Jakarta on July 4 in support of presidential candidate Joko Widodo. The number refers to Mr. Widodo's spot on the election ballot and is being used by his campaign to attract young voters. Sara Schonhardt/The Wall Street Journal

JAKARTA, Indonesia—Clad in multicolored checkered shirts popularized by presidential candidate Joko Widodo, scores of youths gathered in Jakarta to listen to bands, talk politics and eat rice shaped like the number two, the spot where Mr. Widodo's name appears on the election ballot.

"The campaign is fun and simple," Ridwan Alief Prayogi, an 18-year-old management student who will cast his first vote ever on July 9, said at the event late Friday. He's planning to vote for Mr. Widodo, explaining that the candidate, "knows the hopes of the people."

The race between Mr. Widodo and Prabowo Subianto has turned razor close, making the youth vote all the more important.

Voters between the ages of 17 and 29 account for roughly 30% of the 188 million registered to vote in this election, which is the third in the 16 years since Indonesia emerged from the iron-fist of former autocrat Suharto. Indonesians can vote when they turn 17.

Both teams are heavily tapping social media, with Facebook and Twitter proving to be effective ways to get young people involved. Both campaigns have large numbers of youth volunteers.

No public opinion polls are available breaking down how youths split between Mr. Subianto and Mr. Widodo. A recent poll showed they make up about one in 10 of the roughly 11% of undecided voters.

Young supporters of Indonesian presidential candidate Prabowo Subianto gather outside the headquarters of his Gerindra Party's youth wing in Jakarta on July 1. Sara Schonhardt/The Wall Street Journal

Mr. Widodo's army of supporters hopes a simple message that the number two is cool will catch on with youths.

Since campaigning began in May, the number has become part of a hit song called "The Two Finger Salute." It also makes an appearance in animated videos and 60-second clips aimed at persuading young voters to choose the 53-year-old Jakarta governor over his rival, 62-year-old ex-army general Subianto.

Mr. Widodo's volunteers have sent out daily email blasts alerting supporters to discussions and get out the vote concerts. They also suggested hashtags to use when tweeting—Friday's was "#JokowiWins." Jokowi is Mr. Widodo's nickname.

While Mr. Widodo has relied largely on his disparate collection of volunteers, Mr. Subianto has a formidable online machine. Members of his social-media team, averaging 25-years-old, work in shifts to ensure around-the clock campaigning that mimics the firm, top-down leadership style Mr. Subianto espouses.

Noudhy Valdryno, a 21-year-old digital strategist for Mr. Subianto's Gerindra Party, says the team is packaging the political party's message to appeal to young voters.

They recently launched a series of animated Facebook cover images that talk about Mr. Subianto's proposed programs, including more land for farmers and increased self-sufficiency. One reads: "I choose Prabowo-Hatta so that Indonesia will no longer rely on imported food." Hatta Rajasa is Mr. Subianto's vice-presidential running mate.

A video created by a group of young supporters shows youth holding banners that read "Save Indonesia," one of the taglines tied to Mr. Subianto's campaign, interspersed with photos of a handsome, young Mr. Subianto in his military uniform. A rap chorus chants, "Indonesia forward."

Youth-grabbing pitches are apparent from both teams—with each creating stylized illustrations of their candidates' faces and comic books about their programs that are aimed at younger voters.

Enda Nasution, a well-known Indonesian blogger and monitor of social media who supports Mr. Widodo, notes both campaigns have effectively developed youth-friendly messages.

"There are a lot of people who share the content because of the style of the campaign…because they think it's cool," he said of young people's reactions to the youth-focused work by both campaigns.

Pingkan Irwin, 28, a founder of Ayo Vote, a neutral youth group that has organized weekly debate-watching parties, believes young voters are more engaged and excited about the election than in the past.

She says the energy is coming from youths frustrated by years of political gridlock.

"We complain a lot that things are not going well in the country, but we can't keep complaining," said Ms. Irwan. "This is the time when [youths] have to be active…It's a turning point."

In a country where economic growth has slowed, some young people in interviews said they are concerned about employment. They said they want stability and order, and fear growing religious and ethnic intolerance. Urban, educated youths said Indonesia needs to take a stronger role in the world.

Mr. Subianto ticks some of those boxes with his staunchly nationalistic message and image of a firm, no-nonsense leader. Mr. Widodo, who has dramatically increased the minimum wage as governor, has campaigned on a message that he comes from the people and understands their concerns.

A survey conducted by the Indonesian Survey Institute following April's legislative elections estimated that voter turnout among the 17-21 age group was 94%. Actual numbers are likely to be closer to the general turnout of 73%, said Dodi Ambardi, the institute's executive director.

Siti Zuhro, a political researcher from the Indonesian Institute of Sciences, said many young supporters have been energized by the stark differences of the candidates—one a former general with close ties to the Suharto era and the other a plain-speaking furniture exporter turned politician.

"Unlike the 2009 election, youth are emotionally more involved now," she said. "This is not only because of Jokowi and Prabowo, but also because of the use of social media—they can do chatting, arguing, rebutting, they have the freedom to express their views."