He will serve as the government's senior politician and as the president of the Policy and Resources Committee.
He was voted in by 20 votes to 19 ahead of Deputy Peter Ferbrache, with one spoilt paper.
It follows a 20-20 tie in the second and third round of voting. Further ties could have led to the drawing of lots.
Deputy Parkinson, also a former treasury minister, lost out in the first round of voting after polling eight votes, compared to 17 for Deputy St Pier and 15 for Deputy Ferbrache.
The other four members of the committee are due to be elected on Friday.
Deputy St Pier said after the result: "I'm overwhelmed, I feel a little bit ill having gone through that process. I'm sure none of us expected that.
"This is an inauspicious start, to end up with such a divided vote, but I think it re-emphasises what I was saying in my opening speech, the need for us to really work together.
"This is going to be a very difficult States as indeed the last one was. We have some major challenges and what we need to do is really think about where people's skills can be used to best effect, this can't be about personal aspirations."
Former treasury minister Gavin St Pier has been elected first president in the new States of Guernsey structure after a close vote.