Yuzuru Hanyu, 19, won Japan’s first Olympic gold medal in men’s figure skating. (EPA/HOW HWEE YOUNG)

SOCHI, Russia — Japan’s Yuzuru Hanyu overcame a shaky free skate Friday at the Sochi Olympics to hold off his more seasoned rival, three-time world champion Patrick Chan, for figure skating gold.

Both men were trying to earn the first Olympic gold medal in men’s figure skating for their country.

But on a night of far too many falls by medal contenders, Chan failed to seize the golden opportunity and was relegated to silver. Denis Ten of Kazakhstan took bronze.

American Jason Brown finished ninth.

The 19-year-old Brown, of Highland Park, Ill., was making his Olympic debut. Brown performed the Riverdance-inspired free skate that became a YouTube sensation when he staged it at the U.S. championships last month, getting three million hits. In the slow build-up to the spirited section, he had two unsteady landings and put a hand down on one of them. As the tempo quickened, the crowd clapped along and Brown grew more confident. But his total score of 238.37 wasn’t enough for a podium finish.

Hanyu, the leader after Thursday’s short program, fell on his opening quad Salchow and stumbled out of a triple flip. He earned 178.64, which put him in the lead with a total score of 280.09  points.

Hanyu’s missteps created an opening for Chan, who was nearly four points in arrears when he took the ice.

Chan delivered his difficult opening combination, a quad toe-triple toe, beautifully. Then came the errors — a hand down on the quad toe that followed and a step-out on another jump. But his skating remained fluid, and his interpretive skills elegant. Judges gave him higher artistic marks, but lower technical scores, culminating in a total score of 275.62 and ensuring Hanyu’s top-placed finish.