RIO DE JANEIRO —Helen Maroulis hatched her partial obsession with Saori Yoshida two years ago. She studied her wrestling matches. She translated her interviews from Japanese to English to learn how she thought. She smoothed her weaknesses to match Yoshida’s strengths. Maroulis wanted to win an Olympic title, and that meant she needed to beat Yoshida, winner of three gold medals and 13 world championships, idol of a nation, the best female wrestler ever.

Of all the people to topple Yoshida, a 24-year-old from Rockville ranked among the least likely. No American woman had won an Olympic wrestling gold medal. In 43 states, Maryland included, girls must wrestle boys in high school. Maroulis had taken up wrestling following her brother around to wrestling rooms and refusing to leave, a shy girl among maybe 50 boys, too naive to understand no one wanted her there. She confronted boys who refused to wrestle her or — even worse — told her she was pretty good for a girl. She had coaches who told boys to ride her until she quit. She never did, even when it meant going to college in Canada because the NCAA does not recognize women’s wrestling as a sport.

Maroulis’s resilience made her a world champion last year, and Thursday afternoon it led her to the center mat inside Carioca Arena 2, running in circles and holding an American flag across her back. To claim the United States’ first gold medal in women’s wrestling, Maroulis dealt the greatest wrestler ever her first Olympic loss. Maroulis outlasted Yoshida, 4-1, scoring all four points in the final period. Maroulis collapsed to her back and covered her face, tears streaming past her smile.

“This is the hardest thing I’ve ever done, mentally, physically and emotionally,” Maroulis said afterward. “At the end, I was like, ‘Really, I just did this?’ ”

Usain Bolt of Jamaica crosses the finish line to win gold in the 200-meter sprint. Bolt has now won gold in the 100-meter and 200-meter events in three consecutive Olympic games. Jonathan Newton/The Washington Post

The match drew imperfect comparisons to the most famous in American history: the upset Rulon Gardner pulled on Russian Alexander Karelin in the 2000 Sydney Games. Imperfect because Maroulis had achieved far more than Gardner. But the match may make a broader impact, and Karelin shared with Yoshida an aura of impenetrability.

Every four years, USA Wrestling officials craft a plan for how they want their Olympians to develop. Every attribute they name, they find in Yoshida.

“Her picture was on the wall,” U.S. Coach Terry Steiner said.

Yoshida, 33, entered the gold medal match 258-11 dating from 1998. She had lost two international matches, most recently in 2012. She comes from Tsu, Japan, where officials annually award the Saori Yoshida Grand Prize. Her father, Eikatsu, a Japanese wrestling champion and coach, started her wrestling at age 3. Eikatsu died in 2014. Four days later, Yoshida won the World Cup title.

Maroulis had wrestled her twice in the past. Yoshida pinned her both times. They had not wrestled since 2012, changing weight classes, missing each other as Yoshida aged and Maroulis peaked.

“We’ve been talking about beating Yoshida for the past two years,” said Valentin Kalika, Maroulis’s personal coach. “All of her training was to beat Yoshida.”

As a competitor, Maroulis straddles a crooked line between doubt and confidence. Two weeks ago, she daydreamed about booking a flight to Iceland, afraid she would be “the biggest failure at the Olympics,” worried she wouldn’t even make weight. On Thursday morning, she confided in teammate Elena Pirozhkova, who would lose a bronze medal match, that she still couldn’t believe she had become a wrestler, surrounded by the toughest women in the world.

But then she would return to the journal entry she wrote a year ago, after she watched Yoshida beat Swede Sofia Mattsson in a world championship match. She had inscribed her belief she could beat Mattsson and Yoshida at the Olympics with the requisite work.

She navigated the divide with joy. Through studying Yoshida, Maroulis viewed her less as an enemy than an ideal. She admired her work ethic, fortitude and humility too much to hate her. Before she pinned Mattsson in the semifinals, Maroulis peered ahead to consider what an honor it would be to wrestle Yoshida.

“It’s a job,” Maroulis said, “and love does the job better.”

On her way to the mat, Maroulis mouthed, “Christ is in me, and I am enough.” She and Kalika discussed the plan, two years in the making, one last time: Yoshida moved faster straight ahead and shooting at legs, but Maroulis had more lateral quickness. She had to neutralize Yoshida with pressure, to be cautious but aggressive.

The Japanese section of the crowd waved flags and chanted, “Yo-shi-da! Yo-shi-da!” She had won three golds. Maroulis was at her first Olympics.

“I didn’t want to look at Goliath and get scared,” Maroulis said.

Neither wrestler seized control in the first period, which ended with Yoshida up 1-0. Thirty seconds into the second, Maroulis took a shot. Yoshida collapsed on her, quick as advertised, but Maroulis spun behind her to earn a takedown. Two points. A 2-1 lead. “U-S-A!” chants echoed.

With 75 seconds left, the chants switched to “Hel-en!” Yoshida tried to shoot at her legs, but Maroulis twisted and shoved her out, two more points. The crowd erupted, 51 seconds left.

The clocked ticked up toward six minutes. Yoshida dove for Maroulis’s leg, and Maroulis leaned on her. Yoshida wouldn’t let go. Maroulis needed to keep from swinging behind her for two points in the next 20 seconds.

The referee blew her whistle and ordered both wrestlers to restart in the center. Nine seconds. Yoshida shot a leg, and Maroulis blocked. Five seconds. Another shot. Another block. No seconds were left, and it had happened.

Yoshida froze in a heap and bawled, and 34 minutes later, when she walked into the mixed zone after the medal ceremony, she was still crying.

Maroulis collapsed on her back. She cried. She leapt into Kalika’s arms. She dove into a pile of supporters in the crowd — her friends, her boyfriend and her parents, John and Paula, who drove her to every practice and signed every permission slip to let her wrestle boys.

Maroulis gazed upon the flag on the medal and sobbed. “It’s such an honor to be an American,” she thought.

Her country remains behind in her sport at lower levels. Girls have few opportunities to wrestle other girls; three-time world champion Adeline Gray, who was upset in the quarterfinals Thursday, had to sue under Title IX to wrestle in high school.

“I hope with this gold medal, girls will view this as a sport for them,” Maroulis said. “If you knew how I was when I was 7: the shy girl, scared and timid. Even now, I’m not super confident all the time. And wrestling has helped with all of that. Girls can learn so much developing confidence through wrestling.”

Said Steiner: “We need champions like her. We need champions to parade around, someone people are going to hear about.”

They will hear about Helen Maroulis, the blond-braided girl from Rockville, who wouldn’t go away when the boys wanted her to, who grew up and beat the best there ever was.