You are not permitted to download, save or email this image. Visit image gallery to purchase the image.
He staved off a brilliant round by Englishman Tommy Fleetwood, who matched the lowest score in tournament history, a seven-under-par 63 at Shinnecock Hills.
Koepka shot a closing 68 to finish at one-over 281 and become the first to win back-to-back since Curtis Strange in 1988 and 1989.
Koepka had the luxury of requiring only a bogey at the par-four 18th, and he needed it after hooking his approach shot so far left it bounced off the base of a grandstand.
He pitched onto the green and lagged his first putt stiff before tapping in to edge Fleetwood by one stroke.
Dustin Johnson, who started the final round in a four-way tie for the lead with Koepka, Daniel Berger and Tony Finau, shot 70 for third place on three-over.
Johnson, the 2016 champion, was betrayed by his putting for most of the day.
Masters champion Patrick Reed (68) was fourth, three strokes behind Koepka, after his early charge - five birdies in the first seven holes - faltered.
Fleetwood, playing more than two hours ahead of the overnight leaders, had threatened to steal a shocking victory after reeling off four consecutive birdies from the 12th hole.
He had good chances to birdie the final three holes as well, but missed them all including an eight-footer at the last with history beckoning.
After hoisting a six-iron from nearly 200 yards uphill and into the wind at the par-four 18th, his ball covering the flag the entire way before landing gently to leave him with an uphill putt.
The Englishman misread the putt and missed on the low side.
He is the sixth to shoot 63 at a U.S. Open, joining Johnny Miller (1973), Jack Nicklaus (1980), Tom Weiskopf (1980), Vijay Singh (2003) and Justin Thomas (2017).
"I honestly never really thought I was out of it," said world number 12 Fleetwood, who started the day six strokes off the lead.
"I just needed a good start. Looking at the pins you knew they were going to be more accessible. Four-under after seven and it was game on."
Fleetwood lamented missing a 12-foot birdie putt that he left short at the 16th, as well as the chance at the last.
"The putt, I started on the line I wanted to," he said of the 18th.
"It was a little slower than I thought. I knew what it was for. I hit the putt I wanted. It's so steep that green."
Fleetwood, 27, was asked whether he thought his score might be good enough to win, in conditions that although demanding were not as difficult as on Saturday.
The greens were slower and softer, the pin positions were easier and the wind not quite as strong.
"If the set-up was like yesterday I'd feel a lot more comfortable," said Fleetwood, a four-times European Tour winner, speaking while Koepka still had half a round to play.
"There's nothing I can do now."
As he settled in to watch the rest of the round on TV, Koepka birdied the 10th hole after flicking a precise approach shot to take a two-shot lead at even par.
But no sooner had he seemingly grabbed the championship by the throat than he misjudged his tee shot at the par-three 11th and watched his ball rocket over the crowned green and hurtle way beyond into rough.
He did well to salvage bogey and preserve his one-shot lead.
A hot putter ensured he stayed there.