Djokovic will start his campaign against Roberto Carballes Baena, while Federer will play Australian John Millman.
Wimbledon finalists Novak Djokovic and Roger Federer are on a semi-final collision course at the US Open after they were placed in the same half of the draw on Thursday.
Top seed Djokovic, who saved two match points in the All England Club final to deny Federer a record ninth title at the grasscourt championships, will start his campaign against 76th-ranked Roberto Carballes Baena in New York next week.
The Serbian then faces a potential second-round showdown against American Sam Querrey.
Third seed Federer, who won the last of his five Flushing Meadows trophies in 2008, will open against a qualifier as he chases a 21st Grand Slam title.
Djokovic has a 26-22 head-to-record record against Federer, and has won their last four meetings.
They are 3-3 at Flushing Meadows, with Djokovic winning the last three times, most recently in the 2015 final.
On the other side of the draw, second seed Rafael Nadal, who was beaten by Federer in the Wimbledon semi-finals, will play Australian John Millman in the first round of the hardcourt major which starts on Monday.
Millman reached the US Open quarter-finals last year after knocking out Federer in the last 16.
The Spaniard, three-times a champion in New York, could run into 2014 champion Marin Cilic in the fourth round.
Djokovic says he is ready for another Grand Slam tilt, almost two months after claiming his 16th title at Wimbledon.
Speaking at the draw on Thursday, he said the Wimbledon final against Federer was one of the two most memorable matches of his career, along with the six-hour marathon against he won against Nadal in the 2012 Australian Open final.
“It took me time to reflect on everything, relax... and then get back on track,” he said of Wimbledon.
In other first-round matches next week, Austrian fourth seed Dominic Thiem meets 87th-ranked Italian Thomas Fabbiano, while fifth seed Daniil Medvedev begins his campaign against 89th-ranked Indian Prajnesh Gunneswaran.
Medvedev is coming off three successive finals in as many weeks, culminating with victory over David Goffin in Cincinnati on Sunday, which came after the Russian had beaten Djokovic in the semi-finals.
Medvedev could meet Djokovic as early as the quarter-finals in New York.