Portugal won on overall points scored in the four-nation tournament in Dubai after finishing with the same record as the more-fancied Americans.
Samuel Marques kicked over from 35 metres out to secure for the Portuguese a return to France for a second appearance at the World Cup after they competed at the 2007 finals.
It was heartbreak for the USA, who had been 16-13 ahead for the last 20 minutes and were on course to win the tournament but gave away a penalty, for going off their feet in the ruck, with seconds left in the game to allow Marques to snatch away qualification.
Portugal, who led 10-9 at half-time, had a better overall points record at the four-team tournament in the United Arab Emirates, boosted by last Saturday’s 85-0 thumping of Kenya.
Portugal went ahead against the US after eight minutes when speedy winger Raffaele Storti scored a try.
Marques converted and also kicked over three penalties to ensure a place in Pool C at next year’s finals, where they will take on Australia, Fiji, Georgia and Wales.
It was another last-gasp loss for the Americans, who had already faltered with two chances at qualification for France.
The US, who have competed at eight of the previous nine World Cups, were beaten over two matches by Uruguay in their first attempt in the Americas playoff and then upset by Chile, who edged them by a single point on aggregate over two matches in a repechage tie.
Portugal, who lost all four group games in 2007 and conceded more than 200 points, qualified for Dubai after finishing third in the Rugby Europe Championship after Spain were docked points for fielding an ineligible player in the competition.