Majchrzak rallied after dropping the first two sets to win 2-6, 6-7, 6-4, 7-5, 7-6, Polish state news agency PAP reported.
It was the 29-year-old's first career victory over a top-10 player and his first win against Khachanov in five meetings.
The result sends Majchrzak into the US Open third round for the second time in his career.
His run in New York will also lift him to around No. 60 in the world rankings after the tournament—a career high. He is currently ranked 76th, with his previous best at No. 75.
Majchrzak will face Swiss qualifier Leandro Riedi in the next round on Saturday.
(gs)
Source: IAR, PAP