The 23-year-old was due to become a free agent next summer but the Swans were keen to extend his deal after he impressed towards the end of last season on his return from a loan spell with Birmingham.
News of Bartley's deal came less than 24 hours after captain Ashley Williams signed a four-year contract with the club to ward off the advances of Premier League rivals Sunderland.
And Bartley hopes to play a much bigger role in boss Garry Monk's plans this season.
“I spoke to the manager after the last game of the season at Sunderland and he was keen to extend my contract,” Bartley told the club's official website.
“It’s brilliant for me because it’s a show of faith from the club and manager, and this season I really want to repay them for that by playing games and doing myself and the club proud.
“The manager is, first and foremost, an honest guy and he said if I work hard and show my ability then I’ll get a chance.
“The season is demanding with the Premier League and cup competitions, so everyone in the squad will be used and it’s up to them to perform and keep their spot in the team.
“The loan at Birmingham got my confidence back and made me stronger. I feel a better player for the games I was able to play there.
“It’s my third season and I’m only 23, but I feel confident in my own ability and I’m ready to pull that shirt on and do well.”