Alegre made his debut for the Spanish national team in 2003 against Germany. He finished in fourth position with the national team at the 2004 Summer Olympics in Athens, Greece, and in sixth at the 2012 Summer Olympics. However, in between he was part of the 2008 Summer Olympics team which won a silver medal. The midfielder has also played in three World Cups. He took a break from the national team in 2016 to focus on his work. After not having played for three years for the national team he returned in the team in October 2019 for the 2019 FIH Olympic Qualifiers. On 25 May 2021, he was selected in the squad for the 2021 EuroHockey Championship. He retired from playing hockey after the 2020 Summer Olympics.