Bain Capital has agreed to buy Australian software maker MYOB for about A$1.2 billion ($1.3 billion) after Sage Group plc's bid ran into last-minute glitches, two sources with direct knowledge of the matter told Reuters on Saturday.

Bain and Kohlberg Kravis Roberts & Co had re-entered the race for MYOB after market turmoil derailed the UK software group's bid to buy its Australian peer.

Archer and HarbourVest bought MYOB, an abbreviation of the phrase 'Mind Your Own Business', for about A$450 million in 2008.

Archer, HarbourVest and MYOB were not immediately available for comment. Bain declined to comment. The sources were not authorized to speak publicly on the matter because the deal has not been announced.

(Reporting by Stephen Aldred; Editing by Denny Thomas)