Eain Smith's interception late in the ranked West 31 win over the Terrapins at Byrd Stadium.
Geno Smith threw for 388 yards with a touchdown and an interception for the Mountaineers (3-0), who nearly blew a 24-point lead but held on to beat the Terrapins for the sixth straight time.
It was a good test for West Virginia, which opened the season with easy wins over Marshall and Norfolk State and next week hosts SEC powerhouse LSU.
"It's hard to win on the road," said West Virginia head coach Dana Holgorsen. "Every win's a good game. I've said it all three times we've won, we don't take for granted a win."
Danny O'Brien completed 34-of-52 passes for 289 yards with a touchdown and three interceptions in defeat. One of those picks was returned for a score. Davin Meggett rushed for 113 yards with a touchdown for the Terrapins (1-1), who hadn't played since a season-opening win over Miami-Florida on September 5.
West Virginia built a 34-10 lead early in the third quarter, but Maryland scored the next 21 points to pull within three. The Mountaineers then added a field goal with 4:42 remaining to force the Terrapins to go for the end zone on their final possession.
Maryland quickly faced 4th-and-1, but D.J. Adams converted with a five-yard run, and the Terrapins soon reached the West Virginia 37. However, O'Brien threw into double coverage and was picked off by Smith inside the 15-yard line.
"We had a chance to win the ballgame at the end but we didn't get it done," said Maryland head coach Randy Edsall. "There are things that we have to work on; every week there are going to be things that we have to work on. I'm very disappointed that we didn't come out on top because that's what we are shooting for."
The teams combined for 957 yards of offense in a shootout that West Virginia dominated early.
After West Virginia fumbled on its opening possession, Maryland opened the scoring on a 25-yard field goal by Nick Ferrara midway through the first quarter. The Mountaineers responded with the next 24 points.
Smith followed the field goal by directing a 10-play, 88-yard drive for a touchdown. He connected on five consecutive throws during the march, which was aided by a pass interference penalty on a 3rd-and-13 incompletion, setting up Vernard Roberts' nine-yard touchdown run.
Terence Garvin then picked off an O'Brien pass just over a minute later and rumbled 37 yards to the end zone, and West Virginia tacked on a 35-yard field goal from Tyler Bitancurt early in the second quarter for a 17-3 advantage.
O'Brien was intercepted on Maryland's next series, but West Virginia gave it right back when Smith fumbled while being sacked. The trade of turnovers left the Terrapins with the ball at the West Virginia 40, but Maryland couldn't move and turned it over on downs.
It took the Mountaineers just 69 seconds to add to their lead. Smith keyed the quick strike with a 36-yard pass to Ivan McCartney on third down and Andrew Buie finished the five-play set with a 10-yard touchdown run for a 24-3 edge with 8:15 left in the opening half.
Ferrara missed a 48-yard field goal try just over two minutes later, but the Terps got the ball back when West Virginia was stopped short on 4th-and-3 from the Maryland 37. O'Brien then led a 65-yard scoring march and hit Kevin Dorsey in the end zone from 18 yards away for the touchdown to make it 24-10.
West Virginia had 2 1/2 minutes before the break and added a 34-yard field goal from Bitancurt on the final play of the half for a 17-point lead, then took the opening kickoff and marched 78 yards in seven plays for a touchdown. Smith hit a wide open Stedman Bailey in the center of the end zone for a 34- yard score and a 34-10 cushion.
Maryland's first series of the second half reached the West Virginia six-yard line, but O'Brien threw incomplete on fourth down. The Terps got the ball back after a punt and drove 61 yards for a score. Meggett covered the final 20 yards on the ground to make it 34-16, as the two-point conversion failed.
The Terrapins appeared to recover a fumble on the ensuing kickoff, but the play was ruled down by contact. Maryland did get the ball soon after, though, as Dexter McDougle intercepted a tipped pass at the Mountaineer 44-yard line and Adams scored on a six-yard run for a 34-23 contest late in the third.
Maryland's comeback continued on its next series with a 12-play, 66-yard drive that ended in a two-yard touchdown run by Adams. Meggett then bulled into the end zone for the two-point conversion to make it a 34-31 game with 10:29 to play.
The Mountaineers followed by taking nearly six minutes off the clock with a drive inside the Maryland five, but it stalled there and Bitancurt drilled a 21-yard field goal for the important six-point margin.
"We really started good, the first half on all three sides of the ball," noted Holgorsen. "The second half... I thought they outplayed us on all three sides of the ball. Good news is we had enough and had a good drive offensively after the third field goal where we should have gotten a touchdown. We at least got three points to make it a six-point game."
Maryland toned down its uniforms for the second game of the season. After opening the year with an unusual combination of the state flag and school's colors, the Terrapins wore all black from the helmet to their shoes with red numbers trimmed in gold. The helmets were basic black with a stripe of gold, black and red.
West Virginia posted a 31-17 triumph last year in Morgantown and leads the all-time series, 25-21-2...Edsall, in his first year with the Terps after 13 years at Connecticut, fell to 1-7 against the Mountaineers...Bailey had eight catches for 113 yards, while McCartney hauled in eight passes for 101. Tavon Austin led West Virginia with 11 receptions for 122 yards.