After a goalless first half, Kieran Link tapped home the 46th-minute opener for Edgehill from a rebound after a Luke Jones shot was not held by Pier keeper Scott Wardman.
Martin Cooper levelled the scores in the 55th minute, finishing nicely after being set up by Neil Thomas.
Edgehill then took the lead from the penalty spot when a handball against Niall Gibb was punished despite the protests of the visitors, Danny Collins slotting home the spot-kick.
Vandalised Scarborough allotments to be restored as council approves plans to help tackle hundreds stuck on waiting lists
COURT: Scarborough brothers threw man around 'like a rag doll' during vicious street attacks
Post-war asbestos bungalows to be demolished in Scarborough as plans for new terraced homes approved
Scarborough seaweed farm SeaGrown win Government contract to help increase renewable energy
Tractor fire forces police to close road through High Marishes near Malton
With 20 minutes remaining skipper Joe Gallagher burst through from midfield with a powerful run and tidy finish into the bottom corner.
Pier then pulled back another goal with Sam Garnett beating the offside trap in the 80th minute, Pier had a couple of chances to level but Edgehill held firm.
Edgehill boss Steven Clegg said: "Their two goals came from our defensive errors and we deserved the win over the 90 minutes.
"Skipper Joe Gallagher was impressive throughout and got my man of the match award."
Beaten Pier boss Andy Spivey said: "It was a great effort from the Pier lads and fine performances came from Mikey Pickering and Liam Mancrief in defence."
Ayton teenager Tom Varey smashed in four goals as his side won 5-2 at home to Filey Town Reserves in the League Trophy quarter-finals.
Varey put the home side in front midway through the first half with a shot from the edge of the penalty area.
Aaron Howard levelled for the visitors, but James Cooke smashed home a shot from just inside his own half to restore Ayton's slender lead.
Varey, 17, then sidefooted his second of the game to give Ayton some breathing space but Town refused to submit and Ryan Baldry fired in their second.
The teenage ace made it 4-2 with a tap-in at the back post to complete his hat-trick and the hosts' man of the match saved his best until last when he hammered home a 25-yard piledriver to send Ayton into the semis.
Edgehill 3rds join Ayton in the final four after battling back from behind to win 5-3 at home to West Pier Reserves.
Shaun Dodson fired Edgehill in front, but Pier rallied and struck twice to take the lead by half-time, the first a fine 20-yard strike from Zac Hansen and the second a 12-yard shot from player-boss Johnny McGough.
Ben David then equalised for the home team from the penalty spot after Lee Cappleman had been fouled, then Kyle O'Toole finished off a fine move to put Edgehill in front.
Lewis Weller forced home a Lee Cappleman cross to make it 4-2, and although Hansen struck again to give Pier hope, another foul on Lee Cappleman saw a penalty awarded, with Gary Hepples converting this time.
Martyn Jenkinson, who started in central midfield but then moved up front in the second half, and midfielder Ryan Link were the star men for Edgehill, while centre-back Jack Brown was excellent for Pier.
Itis Itis Rovers also moved through to the final four, as their home game was conceded by hosts Fishburn Park after the game was called off due to an unfit pitch.