Locke took charge of first-team affairs for three matches following the sacking of John McGlynn last month and has guided them to a win, draw and defeat in that time.
Club director Sergejus Fedotovas confirmed that Locke has been handed a contract until the end of next season after winning majority approval from the Hearts board.
He told the club's website: "It was Gary Locke who scored more points among the board members.
"I believe that it is right that Gary, Edgaras Jankauskas and Darren Murray continue to be given an opportunity to build on the work they have begun. Gary clearly has the same desire as a coach that he showed as a player for the club and with the support of Edgaras, Darren and the players has has an opportunity to deliver success to the club.
"Our decision provides certainty to everyone through to the end of next season and reinforces the focus we all have in trying to achieve a special chapter in the history of this club on Sunday."
Locke has an instant chance to win a trophy tomorrow when Hearts face St Mirren in the Scottish League Cup final at Hampden Park.