MONACO (AP) — Spain earned the last men's Olympic rugby sevens berth when it scored in the last seconds to upset Samoa 22-19 in the final qualifier on Sunday.

Spain came out of nowhere to complete the 12-team Olympic field.

Not a world series regular or even seeded in Monaco, the Spaniards lost a pool game to Hong Kong 19-0 on Saturday. But on Sunday they overcame Ireland 12-7 from 7-0 down in the quarterfinals, pipped Russia 17-12 with a last-minute try in the semifinals, and stunned the favored Samoans in the final.

Samoa, which won the world series stop in Paris last month, led 19-12 in the second half, but Spain cut the deficit to two points through a Pol Pla try. From a tap penalty with seconds left, Pablo Fontes de Castro drew in the defense, threw a missout pass to Inaki Villanueva on the left wing, and he passed out of a double tackle to give Ignacio Martin a free run in. Martin celebrated before he scored.

"I am still trying to take it in," teammate Angel Lopez said. "This is a dream for us. We are going to be Olympians. We believed that we are good enough, but wow, this is pretty special."

The last women's qualifier is next weekend in Dublin.