New York City and Northern Virginia will be the homes for Amazon.com Inc.’s second and third headquarters, according to people familiar with the matter, ending a more than yearlong public contest that started with 238 candidates and ended with a surprise split of its so-called HQ2.

The imminent announcement is expected as soon as Tuesday, according to the people. Other cities may also receive major sites, some of the people said.

Amazon...