A luminescent europium–organic framework with tubular channels based on the H4BTMIPA ligand (H4BTMIPA = 5,5′-methylenebis(2,4,6-trimethylisophthalic acid)) was assembled and characterized. The [H2N(CH3)2]+ ions as counterions are located in the channels. The cation exchange between [H2N(CH3)2]+ and metal ions resulted in complex 1 that can selectively sense Fe3+ and Al3+ ions through fluorescence quenching and enhancement, respectively.