Darren Grainger celebrated his personal homecoming and helped Georgia State post the program’s first victory over a ranked opponent.

The quarterback from Conway, S.C., grew up about five minutes from the Coastal Carolina campus. He returned home Saturday and directed Georgia State to a 42-40 upset. The junior said he had no idea how many family and friends were in the stands, but was pleased he could provide a win.

“It feels good to be home, and it feels good to get a ‘W’ over a ranked opponent,” Grainger said. “We’ve been trying to get one for a couple of games now, so it feels great. A great team win.”

Coastal Carolina is No. 22 in the Associated Press poll, though it is not ranked in the College Football Playoff rankings, which determine the seeds for the national semifinals. Georgia State lost three times to ranked teams this season, losing to North Carolina, Auburn and Louisiana-Lafayette.

“I’m a believer,” Elliott said. “I don’t ever doubt our players. I don’t doubt our coaches. Our time was coming. It feels really special to beat a good football team like that. We came up short a few other times, but our team finished tonight, and it feels really good.”

It wasn’t easy.

The Panthers had a 42-34 lead after forcing a turnover and scoring. Coastal Carolina quarterback Bryce Carpenter was sacked by Jamil Muhammad and fumbled, with Jontrey Hunter recovering at the 5. Two plays later Tucker Gregg scored from the 4 for his third touchdown.

But the Chanticleers quickly drove 75 yards in eight plays and scored with 1:09 left on a 17-yard pass from Carpenter to Isaiah Likely. After drawing a pass-interference penalty on the first two-point conversion, Coastal Carolina opted to run it on the second try, and Shermari Jones was knocked back by Gore Thomas and swarmed by others at the 1 who prevented him from reaching the end zone.

The onside kick was recovered by Ja’Cyias Credle, and Georgia State was able to run out the clock.

Georgia State (5-5, 4-2 Sun Belt) was led by quarterback Darren Grainger, who completed 18 of 24 passes for 198 yards and two touchdowns. Gregg carried 18 times for 67 yards and tied a school record with three touchdowns. Jamyest Williams ran 11 times for 82 yards and one touchdown.

Coastal Carolina (8-2, 5-2) had its 12-game home win streak stopped and lost its homecoming game. The Chanticleers beat Georgia State 51-0 last season. Carpenter completed 17 of 29 passes for 233 yards, and Braydon Bennett rushed 10 times for 128 yards.

The game didn’t start well for Georgia State, which fell behind 7-0 when Coastal Carolina scored on its first possession and then stopped the Panthers on fourth-and-1. But Georgia State force the Chanticleers to punt and tied the score on Tucker Gregg’s 2-yard run.

Coastal Carolina answered by scoring on its next play from scrimmage when Bennett took a pitch and raced 75 yards for a touchdown. Undeterred, the Panthers tied the score at 14-14 on a 3-yard touchdown pass from Grainger to Aubry Payne, the 10th of his career.

Georgia State took the momentum when Quavian White intercepted a pass that was tipped by Blake Carroll and returned it to the 1. It was the seventh career pick for White, tying Chandon Sullivan for first place on the all-time school record list. Gregg scored from the 1, the 14th of his career, lifting him to third all-time.

Grainger was tackled for a safety after the Panthers were punted deep, but the defense forced a stop and Georgia State drove 75 yards to go ahead 28-16. Williams scored on a 37-yard run, as he ran away from the blitz for the score.

Coastal Carolina went back to basics and answered with a 10-play, 75-yard drive, scoring on Jones’ 8-yard run, but GSU had a 28-23 lead.

The Georgia State defense came up with a huge stop in the third quarter. Coastal Carolina had first-and-goal at the 2, but the Panthers stoned two run plays and forced and incompletion, leaving the Chanticleers to settle for a 24-yard Biscardi Massimo field goal that cut the margin to 28-26.

Coastal Carolina took the lead with 9:15 left by converting on third-and-goal when Jones went off right tackle for an 8-yard touchdown run. Carpenter caught a two-point conversion pass on a “Philly Special” play for a 32-28 lead.

Georgia State drove to the 1, where they faced fourth-and-goal. Elliott opted to be aggressive and went for the touchdown, getting it when Grainger rolled out and hit Terence Dixon in the end zone. The extra point by Noel Ruiz gave the Panthers a 35-34 lead with 4:53 left.

The win puts the Panthers one win away from being eligible for their third consecutive bowl appearance. Georgia State has won four of its past five and returns home Saturday to play Arkansas State.