Mark Appel gambled on himself when he turned down millions to return for his senior season at Stanford.

The right-handed pitcher’s risk worked out beautifully on Thursday when the Houston Astros selected him No. 1 overall in the Major League Baseball amateur draft.

The product of Monte Vista High-Danville is the first Bay Area player to go No. 1 since Bellarmine College Prep product Pat Burrell went first to the Philadelphia Phillies in 1998. Appel is the first player from a Bay Area college to be the draft’s top selection.

The Astros also had the top pick last year and were expected to select Appel then, but they instead went with Puerto Rican shortstop Carlos Correa. They got a second chance and didn’t pass on Appel this time.

A native of Houston who moved to the Bay Area when he was 12, Appel is thrilled to be returning to his hometown.

“It means a lot,” Appel said in an interview on the MLB Network. “This has just been such a surreal moment for me and my family, just knowing I’m going back home. It’s really an honor.”

Appel, who is represented by agent Scott Boras, turned down a reported $3.8 million last year when he didn’t sign with the Pittsburgh Pirates after they drafted him No. 8 overall. He also reportedly rejected a $6 million offer made by the Astros in pre-draft discussions, prompting them to bypass Appel.

It was considered a risk to return to Stanford, but he improved his game and could sign for as much as $7,790,400, the slotted salary for this year’s top pick.

“There were a lot of ways he could’ve gone after his disappointment last year of not being selected where he thought he really should’ve gone,” Astros general manager Jeff Luhnow said on the MLB Network. “But he went out there, put that behind him and just performed better. His pitches got better, his command got better. And he proved to us that he’s not that far away from being a guy that can be here in Houston and helping our team.”

The 6-foot-5, 215-pound Appel features a mid-90s fastball along with an above-average slider and changeup.

“He’s the most advanced pitcher in this draft and might be the quickest to the big leagues,” said MLB Network analyst John Hart, a former GM for the Cleveland Indians and Texas Rangers.

Luhnow agrees he could be on the fast track.

“He’s a polished college pitcher and those guys tend to be able to move quickly. But we’re not going to be in any rush right now,” he said. “It’s a big difference between the major leagues and college baseball, but I do believe in time Mark Appel will be pitching in Houston and pitching in the top of our rotation.”

Appel leaves Stanford as its career leader in strikeouts and ranks fourth in innings pitched and sixth in wins.

“Our program could not be happier for Mark Appel,” Stanford coach Mark Marquess said in a statement. “Mark ranks right up there with the elite pitchers to play for Stanford. He has not only been an incredible performer and leader on the field, but a great human being off the field.”

This is the third time Appel has been drafted. He went in the 15th round to the Detroit Tigers coming out of high school in the 2009 draft but didn’t sign and instead went to Stanford.

Follow Jimmy Durkin at Twitter.com/Jimmy_Durkin.