The hosts took the lead inside the first two minutes of the match when Jack Burrows found room at the edge of the box before firing a low shot past a helpless Kyle Moran.
The visiting goalkeeper then made a couple of routine saves as Dalkeith Thistle looked to capitalise upon a period of early pressure.
But the St Andrews United players gradually hauled themselves into the contest.
Scott Russell narrowly failed to convert a superb cross from the left by Lewis Sawers and Matthew Hutchison failed to trouble home goalkeeper Shea Dowie from a one-on-one situation.
Saints played some neat passing football as the interval approached and Sawers blasted a great opportunity over the bar.
The score remained 1-0 to Dalkeith heading into the break, though Jack Morgan almost scored from an offside position right at the end of the first half.
Referee Harris made another poor decision at the beginning of the second-half when he awarded a corner much to everybody’s surprise.
The home players made the most of their good fortune.
Darren Leslie placed an accurate cross from the corner spot into a dangerous area and Burrows headed the ball past Moran.
The loss of that goal clearly rattled the visitors and Burrows clipped the post shortly afterwards.
However, Saints again enjoyed a further period of possession as the second half progressed and Reece Redpath narrowly missed the far post following a clever passing move.
The action raged from end to end and Moran did well to prevent Morgan from scoring at the back post before Kevin Giese dragged a shot wide of target.
Giese then kicked Moran in the face as he continued to run forward and the referee amazed the United players, coaches and fans by awarding a penalty kick.
Moran eventually faced the spot kick after a period of recovery but the young goalie did not have to make a save as Burrows missed the right-hand post by some distance.
The St Andrews United boys therefore retained some belief that they could pinch a point from the match and they gained a lifeline when Scott Russell scored his first ever goal for the club.
The impressive Ross Cunningham fed the ball wide to Sawers and the winger cleverly cut inside his opposite number prior to picking out Russell with a well-weighted pass.
The former Glenrothes striker took a decent touch before composing himself and finding the net with a powerful drive in the 83rd minute.
The visitors pressed forward in search of an equaliser yet the referee struggled to keep control of proceedings as both sets of players could feel the tension rising.
Aitchison from Dalkeith was lucky to escape punishment for persistent fouling.
Burrows used his size and determination to frustrate the United defence and he again hit the woodwork with a header in the 85th minute as the game petered out.